-
Notifications
You must be signed in to change notification settings - Fork 27
/
test_cast.py
137 lines (120 loc) · 4.12 KB
/
test_cast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Copyright (C) 2014 ETH Zurich, Institute for Astronomy
"""
Test functions for `hope` module.
"""
from __future__ import print_function, division, absolute_import, unicode_literals
import numpy as np
import hope, itertools, pytest, sys, sysconfig, os, shutil
from test.utilities import random, check, make_test, JENKINS, min_dtypes, dtypes, shapes, setup_module, setup_method, teardown_module
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_bool_(dtype):
def fkt(a):
return np.bool_(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_int_(dtype):
def fkt(a):
return np.int_(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_intc(dtype):
def fkt(a):
return np.intc(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_int8(dtype):
def fkt(a):
return np.int8(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_int16(dtype):
def fkt(a):
return np.int16(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_int32(dtype):
def fkt(a):
return np.int32(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_int64(dtype):
def fkt(a):
return np.int64(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_uint8(dtype):
def fkt(a):
return np.uint8(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_uint16(dtype):
def fkt(a):
return np.uint16(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_uint32(dtype):
def fkt(a):
return np.uint32(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_uint64(dtype):
def fkt(a):
return np.uint64(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_float_(dtype):
def fkt(a):
return np.float_(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_float32(dtype):
def fkt(a):
return np.float32(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)
@pytest.mark.parametrize("dtype", [dtype for dtype in dtypes if dtype != float])
def test_func_float64(dtype):
def fkt(a):
return np.float64(a)
hfkt = hope.jit(fkt)
ao, ah = random(dtype, [])
co, ch = fkt(ao), hfkt(ah)
assert type(co) == type(ch)