Skip to content

Commit 68fa17a

Browse files
committed
Run dpnp.tests.test_ndarray to check if it causes crashes
Enable more USM type relating tests
1 parent f4b967f commit 68fa17a

File tree

2 files changed

+125
-122
lines changed

2 files changed

+125
-122
lines changed

conda-recipe/run_test.bat

+3
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@ if %errorlevel% neq 0 exit 1
3737
"%PYTHON%" -m dpctl -f
3838
if %errorlevel% neq 0 exit 1
3939

40+
"%PYTHON%" -m pytest -ra --pyargs dpnp.tests.test_ndarray
41+
if %errorlevel% neq 0 exit 1
42+
4043
"%PYTHON%" -m pytest -ra --pyargs dpnp
4144
if %errorlevel% neq 0 exit 1

dpnp/tests/test_usm_type.py

+122-122
Original file line numberDiff line numberDiff line change
@@ -36,163 +36,163 @@ def test_coerced_usm_types_add(usm_type_x, usm_type_y):
3636
assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
3737

3838

39-
# @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
40-
# @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
41-
# def test_coerced_usm_types_mul(usm_type_x, usm_type_y):
42-
# x = dp.arange(10, usm_type=usm_type_x)
43-
# y = dp.arange(10, usm_type=usm_type_y)
39+
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
40+
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
41+
def test_coerced_usm_types_mul(usm_type_x, usm_type_y):
42+
x = dp.arange(10, usm_type=usm_type_x)
43+
y = dp.arange(10, usm_type=usm_type_y)
4444

45-
# z = 3 * x * y * 1.5
45+
z = 3 * x * y * 1.5
4646

47-
# # inplace multiply
48-
# z *= x
49-
# z *= 4.8
47+
# inplace multiply
48+
z *= x
49+
z *= 4.8
5050

51-
# assert x.usm_type == usm_type_x
52-
# assert y.usm_type == usm_type_y
53-
# assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
51+
assert x.usm_type == usm_type_x
52+
assert y.usm_type == usm_type_y
53+
assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
5454

5555

56-
# @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
57-
# @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
58-
# def test_coerced_usm_types_subtract(usm_type_x, usm_type_y):
59-
# x = dp.arange(50, usm_type=usm_type_x)
60-
# y = dp.arange(50, usm_type=usm_type_y)
56+
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
57+
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
58+
def test_coerced_usm_types_subtract(usm_type_x, usm_type_y):
59+
x = dp.arange(50, usm_type=usm_type_x)
60+
y = dp.arange(50, usm_type=usm_type_y)
6161

62-
# z = 20 - x - y - 7.4
62+
z = 20 - x - y - 7.4
6363

64-
# # inplace subtract
65-
# z -= x
66-
# z -= -3.4
64+
# inplace subtract
65+
z -= x
66+
z -= -3.4
6767

68-
# assert x.usm_type == usm_type_x
69-
# assert y.usm_type == usm_type_y
70-
# assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
68+
assert x.usm_type == usm_type_x
69+
assert y.usm_type == usm_type_y
70+
assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
7171

7272

73-
# @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
74-
# @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
75-
# def test_coerced_usm_types_divide(usm_type_x, usm_type_y):
76-
# x = dp.arange(120, usm_type=usm_type_x)
77-
# y = dp.arange(120, usm_type=usm_type_y)
73+
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
74+
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
75+
def test_coerced_usm_types_divide(usm_type_x, usm_type_y):
76+
x = dp.arange(120, usm_type=usm_type_x)
77+
y = dp.arange(120, usm_type=usm_type_y)
7878

79-
# z = 2 / x / y / 1.5
79+
z = 2 / x / y / 1.5
8080

81-
# # inplace divide
82-
# z /= x
83-
# z /= -2.4
81+
# inplace divide
82+
z /= x
83+
z /= -2.4
8484

85-
# assert x.usm_type == usm_type_x
86-
# assert y.usm_type == usm_type_y
87-
# assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
85+
assert x.usm_type == usm_type_x
86+
assert y.usm_type == usm_type_y
87+
assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
8888

8989

90-
# @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
91-
# @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
92-
# def test_coerced_usm_types_remainder(usm_type_x, usm_type_y):
93-
# x = dp.arange(100, usm_type=usm_type_x).reshape(10, 10)
94-
# y = dp.arange(100, usm_type=usm_type_y).reshape(10, 10)
95-
# y = y.T + 1
90+
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
91+
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
92+
def test_coerced_usm_types_remainder(usm_type_x, usm_type_y):
93+
x = dp.arange(100, usm_type=usm_type_x).reshape(10, 10)
94+
y = dp.arange(100, usm_type=usm_type_y).reshape(10, 10)
95+
y = y.T + 1
9696

97-
# z = 100 % y
98-
# z = y % 7
99-
# z = x % y
97+
z = 100 % y
98+
z = y % 7
99+
z = x % y
100100

101-
# # inplace remainder
102-
# z %= y
103-
# z %= 5
101+
# inplace remainder
102+
z %= y
103+
z %= 5
104104

105-
# assert x.usm_type == usm_type_x
106-
# assert y.usm_type == usm_type_y
107-
# assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
105+
assert x.usm_type == usm_type_x
106+
assert y.usm_type == usm_type_y
107+
assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
108108

109109

110-
# @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
111-
# @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
112-
# def test_coerced_usm_types_floor_divide(usm_type_x, usm_type_y):
113-
# x = dp.arange(100, usm_type=usm_type_x).reshape(10, 10)
114-
# y = dp.arange(100, usm_type=usm_type_y).reshape(10, 10)
115-
# x = x + 1.5
116-
# y = y.T + 0.5
110+
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
111+
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
112+
def test_coerced_usm_types_floor_divide(usm_type_x, usm_type_y):
113+
x = dp.arange(100, usm_type=usm_type_x).reshape(10, 10)
114+
y = dp.arange(100, usm_type=usm_type_y).reshape(10, 10)
115+
x = x + 1.5
116+
y = y.T + 0.5
117117

118-
# z = 3.4 // y
119-
# z = y // 2.7
120-
# z = x // y
118+
z = 3.4 // y
119+
z = y // 2.7
120+
z = x // y
121121

122-
# # inplace floor_divide
123-
# z //= y
124-
# z //= 2.5
122+
# inplace floor_divide
123+
z //= y
124+
z //= 2.5
125125

126-
# assert x.usm_type == usm_type_x
127-
# assert y.usm_type == usm_type_y
128-
# assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
126+
assert x.usm_type == usm_type_x
127+
assert y.usm_type == usm_type_y
128+
assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
129129

130130

131-
# @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
132-
# @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
133-
# def test_coerced_usm_types_power(usm_type_x, usm_type_y):
134-
# x = dp.arange(70, usm_type=usm_type_x).reshape((7, 5, 2))
135-
# y = dp.arange(70, usm_type=usm_type_y).reshape((7, 5, 2))
131+
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
132+
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
133+
def test_coerced_usm_types_power(usm_type_x, usm_type_y):
134+
x = dp.arange(70, usm_type=usm_type_x).reshape((7, 5, 2))
135+
y = dp.arange(70, usm_type=usm_type_y).reshape((7, 5, 2))
136136

137-
# z = 2**x**y**1.5
138-
# z **= x
139-
# z **= 1.7
137+
z = 2**x**y**1.5
138+
z **= x
139+
z **= 1.7
140140

141-
# assert x.usm_type == usm_type_x
142-
# assert y.usm_type == usm_type_y
143-
# assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
141+
assert x.usm_type == usm_type_x
142+
assert y.usm_type == usm_type_y
143+
assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
144144

145145

146-
# @pytest.mark.parametrize(
147-
# "func, args",
148-
# [
149-
# pytest.param("copy", ["x0"]),
150-
# pytest.param("diag", ["x0"]),
151-
# pytest.param("empty_like", ["x0"]),
152-
# pytest.param("full", ["10", "x0[3]"]),
153-
# pytest.param("full_like", ["x0", "4"]),
154-
# pytest.param("geomspace", ["x0[0:3]", "8", "4"]),
155-
# pytest.param("geomspace", ["1", "x0[3:5]", "4"]),
156-
# pytest.param("linspace", ["x0[0:2]", "8", "4"]),
157-
# pytest.param("linspace", ["0", "x0[3:5]", "4"]),
158-
# pytest.param("logspace", ["x0[0:2]", "8", "4"]),
159-
# pytest.param("logspace", ["0", "x0[3:5]", "4"]),
160-
# pytest.param("ones_like", ["x0"]),
161-
# pytest.param("vander", ["x0"]),
162-
# pytest.param("zeros_like", ["x0"]),
163-
# ],
164-
# )
165-
# @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
166-
# @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
167-
# def test_array_creation_from_1d_array(func, args, usm_type_x, usm_type_y):
168-
# x0 = dp.full(10, 3, usm_type=usm_type_x)
169-
# new_args = [eval(val, {"x0": x0}) for val in args]
146+
@pytest.mark.parametrize(
147+
"func, args",
148+
[
149+
pytest.param("copy", ["x0"]),
150+
pytest.param("diag", ["x0"]),
151+
pytest.param("empty_like", ["x0"]),
152+
pytest.param("full", ["10", "x0[3]"]),
153+
pytest.param("full_like", ["x0", "4"]),
154+
pytest.param("geomspace", ["x0[0:3]", "8", "4"]),
155+
pytest.param("geomspace", ["1", "x0[3:5]", "4"]),
156+
pytest.param("linspace", ["x0[0:2]", "8", "4"]),
157+
pytest.param("linspace", ["0", "x0[3:5]", "4"]),
158+
pytest.param("logspace", ["x0[0:2]", "8", "4"]),
159+
pytest.param("logspace", ["0", "x0[3:5]", "4"]),
160+
pytest.param("ones_like", ["x0"]),
161+
pytest.param("vander", ["x0"]),
162+
pytest.param("zeros_like", ["x0"]),
163+
],
164+
)
165+
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
166+
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
167+
def test_array_creation_from_1d_array(func, args, usm_type_x, usm_type_y):
168+
x0 = dp.full(10, 3, usm_type=usm_type_x)
169+
new_args = [eval(val, {"x0": x0}) for val in args]
170170

171-
# x = getattr(dp, func)(*new_args)
172-
# y = getattr(dp, func)(*new_args, usm_type=usm_type_y)
171+
x = getattr(dp, func)(*new_args)
172+
y = getattr(dp, func)(*new_args, usm_type=usm_type_y)
173173

174-
# assert x.usm_type == usm_type_x
175-
# assert y.usm_type == usm_type_y
174+
assert x.usm_type == usm_type_x
175+
assert y.usm_type == usm_type_y
176176

177177

178-
# @pytest.mark.parametrize(
179-
# "func, args",
180-
# [
181-
# pytest.param("diag", ["x0"]),
182-
# pytest.param("diagflat", ["x0"]),
183-
# ],
184-
# )
185-
# @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
186-
# @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
187-
# def test_array_creation_from_2d_array(func, args, usm_type_x, usm_type_y):
188-
# x0 = dp.arange(25, usm_type=usm_type_x).reshape(5, 5)
189-
# new_args = [eval(val, {"x0": x0}) for val in args]
178+
@pytest.mark.parametrize(
179+
"func, args",
180+
[
181+
pytest.param("diag", ["x0"]),
182+
pytest.param("diagflat", ["x0"]),
183+
],
184+
)
185+
@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
186+
@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
187+
def test_array_creation_from_2d_array(func, args, usm_type_x, usm_type_y):
188+
x0 = dp.arange(25, usm_type=usm_type_x).reshape(5, 5)
189+
new_args = [eval(val, {"x0": x0}) for val in args]
190190

191-
# x = getattr(dp, func)(*new_args)
192-
# y = getattr(dp, func)(*new_args, usm_type=usm_type_y)
191+
x = getattr(dp, func)(*new_args)
192+
y = getattr(dp, func)(*new_args, usm_type=usm_type_y)
193193

194-
# assert x.usm_type == usm_type_x
195-
# assert y.usm_type == usm_type_y
194+
assert x.usm_type == usm_type_x
195+
assert y.usm_type == usm_type_y
196196

197197

198198
# @pytest.mark.parametrize(

0 commit comments

Comments
 (0)