Skip to content

Commit 3c0f249

Browse files
Update some of the dpnp tests to run on Iris Xe (#1472)
* Update tests to test_linalg * Remove skip_dtype_not_supported func * Add support complex64 for dpnp.take * Fix test_sort.py * Fix test_special.py * Use dpnp.default_float_type for test_print_dpnp_nd * A small update skipped_tests * Fix remarks
1 parent c7cdd41 commit 3c0f249

10 files changed

+123
-181
lines changed

dpnp/dpnp_array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class dpnp_array:
6262
def __init__(
6363
self,
6464
shape,
65-
dtype="f8",
65+
dtype=None,
6666
buffer=None,
6767
offset=0,
6868
strides=None,

tests/skipped_tests.tbl

-37
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,6 @@ tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpct
3939
tests/test_arraymanipulation.py::TestHstack::test_generator
4040
tests/test_arraymanipulation.py::TestVstack::test_generator
4141

42-
tests/test_dparray.py::test_astype[[]-float64-float64]
43-
tests/test_dparray.py::test_astype[[]-float64-float32]
44-
tests/test_dparray.py::test_astype[[]-float64-int64]
45-
tests/test_dparray.py::test_astype[[]-float64-int32]
46-
tests/test_dparray.py::test_astype[[]-float64-bool]
47-
tests/test_dparray.py::test_astype[[]-float64-complex]
48-
tests/test_dparray.py::test_astype[[]-float32-float64]
49-
tests/test_dparray.py::test_astype[[]-float32-float32]
50-
tests/test_dparray.py::test_astype[[]-float32-int64]
51-
tests/test_dparray.py::test_astype[[]-float32-int32]
52-
tests/test_dparray.py::test_astype[[]-float32-bool]
53-
tests/test_dparray.py::test_astype[[]-float32-complex]
54-
tests/test_dparray.py::test_astype[[]-int64-float64]
55-
tests/test_dparray.py::test_astype[[]-int64-float32]
56-
tests/test_dparray.py::test_astype[[]-int64-int64]
57-
tests/test_dparray.py::test_astype[[]-int64-int32]
58-
tests/test_dparray.py::test_astype[[]-int64-bool]
59-
tests/test_dparray.py::test_astype[[]-int64-complex]
60-
tests/test_dparray.py::test_astype[[]-int32-float64]
61-
tests/test_dparray.py::test_astype[[]-int32-float32]
62-
tests/test_dparray.py::test_astype[[]-int32-int64]
63-
tests/test_dparray.py::test_astype[[]-int32-int32]
64-
tests/test_dparray.py::test_astype[[]-int32-bool]
65-
tests/test_dparray.py::test_astype[[]-int32-complex]
66-
tests/test_dparray.py::test_astype[[]-bool-float64]
67-
tests/test_dparray.py::test_astype[[]-bool-float32]
68-
tests/test_dparray.py::test_astype[[]-bool-int64]
69-
tests/test_dparray.py::test_astype[[]-bool-int32]
70-
tests/test_dparray.py::test_astype[[]-bool-bool]
71-
tests/test_dparray.py::test_astype[[]-bool-complex]
72-
tests/test_dparray.py::test_astype[[]-complex-float64]
73-
tests/test_dparray.py::test_astype[[]-complex-float32]
74-
tests/test_dparray.py::test_astype[[]-complex-int64]
75-
tests/test_dparray.py::test_astype[[]-complex-int32]
76-
tests/test_dparray.py::test_astype[[]-complex-bool]
77-
tests/test_dparray.py::test_astype[[]-complex-complex]
78-
7942
tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
8043
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
8144
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]

tests/skipped_tests_gpu.tbl

-37
Original file line numberDiff line numberDiff line change
@@ -239,43 +239,6 @@ tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpct
239239
tests/test_arraymanipulation.py::TestHstack::test_generator
240240
tests/test_arraymanipulation.py::TestVstack::test_generator
241241

242-
tests/test_dparray.py::test_astype[[]-float64-float64]
243-
tests/test_dparray.py::test_astype[[]-float64-float32]
244-
tests/test_dparray.py::test_astype[[]-float64-int64]
245-
tests/test_dparray.py::test_astype[[]-float64-int32]
246-
tests/test_dparray.py::test_astype[[]-float64-bool]
247-
tests/test_dparray.py::test_astype[[]-float64-complex]
248-
tests/test_dparray.py::test_astype[[]-float32-float64]
249-
tests/test_dparray.py::test_astype[[]-float32-float32]
250-
tests/test_dparray.py::test_astype[[]-float32-int64]
251-
tests/test_dparray.py::test_astype[[]-float32-int32]
252-
tests/test_dparray.py::test_astype[[]-float32-bool]
253-
tests/test_dparray.py::test_astype[[]-float32-complex]
254-
tests/test_dparray.py::test_astype[[]-int64-float64]
255-
tests/test_dparray.py::test_astype[[]-int64-float32]
256-
tests/test_dparray.py::test_astype[[]-int64-int64]
257-
tests/test_dparray.py::test_astype[[]-int64-int32]
258-
tests/test_dparray.py::test_astype[[]-int64-bool]
259-
tests/test_dparray.py::test_astype[[]-int64-complex]
260-
tests/test_dparray.py::test_astype[[]-int32-float64]
261-
tests/test_dparray.py::test_astype[[]-int32-float32]
262-
tests/test_dparray.py::test_astype[[]-int32-int64]
263-
tests/test_dparray.py::test_astype[[]-int32-int32]
264-
tests/test_dparray.py::test_astype[[]-int32-bool]
265-
tests/test_dparray.py::test_astype[[]-int32-complex]
266-
tests/test_dparray.py::test_astype[[]-bool-float64]
267-
tests/test_dparray.py::test_astype[[]-bool-float32]
268-
tests/test_dparray.py::test_astype[[]-bool-int64]
269-
tests/test_dparray.py::test_astype[[]-bool-int32]
270-
tests/test_dparray.py::test_astype[[]-bool-bool]
271-
tests/test_dparray.py::test_astype[[]-bool-complex]
272-
tests/test_dparray.py::test_astype[[]-complex-float64]
273-
tests/test_dparray.py::test_astype[[]-complex-float32]
274-
tests/test_dparray.py::test_astype[[]-complex-int64]
275-
tests/test_dparray.py::test_astype[[]-complex-int32]
276-
tests/test_dparray.py::test_astype[[]-complex-bool]
277-
tests/test_dparray.py::test_astype[[]-complex-complex]
278-
279242
tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
280243
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
281244
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]

tests/test_amin_amax.py

+22-45
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,46 @@
11
import numpy
22
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal
34

45
import dpnp
56

7+
from .helper import get_all_dtypes
68

7-
@pytest.mark.parametrize("type", [numpy.float64], ids=["float64"])
8-
def test_amax_float64(type):
9+
10+
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
11+
def test_amax(dtype):
912
a = numpy.array(
1013
[
1114
[[-2.0, 3.0], [9.1, 0.2]],
1215
[[-2.0, 5.0], [-2, -1.2]],
1316
[[1.0, -2.0], [5.0, -1.1]],
14-
]
17+
],
18+
dtype=dtype,
1519
)
1620
ia = dpnp.array(a)
1721

1822
for axis in range(len(a)):
1923
result = dpnp.amax(ia, axis=axis)
2024
expected = numpy.amax(a, axis=axis)
21-
numpy.testing.assert_array_equal(expected, result)
22-
23-
24-
@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"])
25-
def test_amax_int(type):
26-
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9])
27-
ia = dpnp.array(a)
25+
assert_allclose(expected, result)
2826

29-
result = dpnp.amax(ia)
30-
expected = numpy.amax(a)
31-
numpy.testing.assert_array_equal(expected, result)
3227

33-
34-
@pytest.mark.parametrize("type", [numpy.float64], ids=["float64"])
35-
def test_amin_float64(type):
28+
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
29+
def test_amin(dtype):
3630
a = numpy.array(
3731
[
3832
[[-2.0, 3.0], [9.1, 0.2]],
3933
[[-2.0, 5.0], [-2, -1.2]],
4034
[[1.0, -2.0], [5.0, -1.1]],
41-
]
35+
],
36+
dtype=dtype,
4237
)
4338
ia = dpnp.array(a)
4439

4540
for axis in range(len(a)):
4641
result = dpnp.amin(ia, axis=axis)
4742
expected = numpy.amin(a, axis=axis)
48-
numpy.testing.assert_array_equal(expected, result)
49-
50-
51-
@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"])
52-
def test_amin_int(type):
53-
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9])
54-
ia = dpnp.array(a)
55-
56-
result = dpnp.amin(ia)
57-
expected = numpy.amin(a)
58-
numpy.testing.assert_array_equal(expected, result)
43+
assert_allclose(expected, result)
5944

6045

6146
def _get_min_max_input(type, shape):
@@ -71,46 +56,38 @@ def _get_min_max_input(type, shape):
7156

7257

7358
@pytest.mark.usefixtures("allow_fall_back_on_numpy")
74-
@pytest.mark.parametrize(
75-
"type",
76-
[numpy.float64, numpy.float32, numpy.int64, numpy.int32],
77-
ids=["float64", "float32", "int64", "int32"],
78-
)
59+
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
7960
@pytest.mark.parametrize(
8061
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
8162
)
82-
def test_amax(type, shape):
83-
a = _get_min_max_input(type, shape)
63+
def test_amax_diff_shape(dtype, shape):
64+
a = _get_min_max_input(dtype, shape)
8465

8566
ia = dpnp.array(a)
8667

8768
np_res = numpy.amax(a)
8869
dpnp_res = dpnp.amax(ia)
89-
numpy.testing.assert_array_equal(dpnp_res, np_res)
70+
assert_array_equal(dpnp_res, np_res)
9071

9172
np_res = a.max()
9273
dpnp_res = ia.max()
9374
numpy.testing.assert_array_equal(dpnp_res, np_res)
9475

9576

9677
@pytest.mark.usefixtures("allow_fall_back_on_numpy")
97-
@pytest.mark.parametrize(
98-
"type",
99-
[numpy.float64, numpy.float32, numpy.int64, numpy.int32],
100-
ids=["float64", "float32", "int64", "int32"],
101-
)
78+
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
10279
@pytest.mark.parametrize(
10380
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
10481
)
105-
def test_amin(type, shape):
106-
a = _get_min_max_input(type, shape)
82+
def test_amin_diff_shape(dtype, shape):
83+
a = _get_min_max_input(dtype, shape)
10784

10885
ia = dpnp.array(a)
10986

11087
np_res = numpy.amin(a)
11188
dpnp_res = dpnp.amin(ia)
112-
numpy.testing.assert_array_equal(dpnp_res, np_res)
89+
assert_array_equal(dpnp_res, np_res)
11390

11491
np_res = a.min()
11592
dpnp_res = ia.min()
116-
numpy.testing.assert_array_equal(dpnp_res, np_res)
93+
assert_array_equal(dpnp_res, np_res)

tests/test_arraycreation.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
import dpnp
1616

17-
from .helper import get_all_dtypes
17+
from .helper import (
18+
get_all_dtypes,
19+
has_support_aspect64,
20+
)
1821

1922

2023
@pytest.mark.parametrize(
@@ -115,7 +118,12 @@ def test_eye(N, M, k, dtype, order):
115118

116119

117120
@pytest.mark.usefixtures("allow_fall_back_on_numpy")
118-
@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False))
121+
@pytest.mark.parametrize(
122+
"dtype",
123+
get_all_dtypes(
124+
no_float16=False, no_none=False if has_support_aspect64() else True
125+
),
126+
)
119127
def test_frombuffer(dtype):
120128
buffer = b"12345678ABCDEF00"
121129
func = lambda xp: xp.frombuffer(buffer, dtype=dtype)
@@ -607,7 +615,11 @@ def test_linspace(start, stop, num, dtype):
607615
if numpy.issubdtype(dtype, dpnp.integer):
608616
assert_allclose(func(numpy), func(dpnp), rtol=1)
609617
else:
610-
assert_allclose(func(numpy), func(dpnp), atol=numpy.finfo(dtype).eps)
618+
if dtype is None and not has_support_aspect64():
619+
dtype = dpnp.float32
620+
assert_allclose(
621+
func(numpy), func(dpnp), rtol=1e-06, atol=numpy.finfo(dtype).eps
622+
)
611623

612624

613625
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)