Skip to content

Commit cf91bc4

Browse files
committed
Added more dtypes for minins tests and manipulation tests.
1 parent c88cfe4 commit cf91bc4

File tree

2 files changed

+62
-55
lines changed

2 files changed

+62
-55
lines changed

tests/test_manipulation.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@
44

55
import dpnp
66

7-
from .helper import has_support_aspect64
7+
from .helper import (
8+
get_all_dtypes,
9+
get_complex_dtypes,
10+
get_float_dtypes,
11+
)
812

913
testdata = []
1014
testdata += [
1115
([True, False, True], dtype)
12-
for dtype in ["float32", "int32", "int64", "bool"]
16+
for dtype in get_all_dtypes(no_none=True, no_complex=True)
17+
]
18+
testdata += [
19+
([1, -1, 0], dtype)
20+
for dtype in get_all_dtypes(no_none=True, no_bool=True, no_complex=True)
1321
]
14-
testdata += [([1, -1, 0], dtype) for dtype in ["float32", "int32", "int64"]]
15-
testdata += [([0.1, 0.0, -0.1], dtype) for dtype in ["float32"]]
16-
if has_support_aspect64():
17-
testdata += [([True, False, True], dtype) for dtype in ["float64"]]
18-
testdata += [([1, -1, 0], dtype) for dtype in ["float64"]]
19-
testdata += [([0.1, 0.0, -0.1], dtype) for dtype in ["float64"]]
20-
testdata += [([1j, -1j, 1 - 2j], dtype) for dtype in ["complex128"]]
22+
testdata += [([0.1, 0.0, -0.1], dtype) for dtype in get_float_dtypes()]
23+
testdata += [([1j, -1j, 1 - 2j], dtype) for dtype in get_complex_dtypes()]
2124

2225

2326
@pytest.mark.parametrize("in_obj, out_dtype", testdata)
2427
def test_copyto_dtype(in_obj, out_dtype):
28+
if out_dtype == dpnp.complex64:
29+
pytest.skip("SAT-6016: dpnp.copyto() do not work with complex64 dtype")
2530
ndarr = numpy.array(in_obj)
2631
expected = numpy.empty(ndarr.size, dtype=out_dtype)
2732
numpy.copyto(expected, ndarr)

tests/test_mixins.py

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,72 +4,74 @@
44

55
import dpnp as inp
66

7+
from .helper import get_float_dtypes
8+
79

810
class TestMatMul(unittest.TestCase):
911
def test_matmul(self):
1012
array_data = [1.0, 2.0, 3.0, 4.0]
1113
size = 2
1214

13-
# DPNP
14-
array1 = inp.reshape(
15-
inp.array(array_data, dtype=inp.float32), (size, size)
16-
)
17-
array2 = inp.reshape(
18-
inp.array(array_data, dtype=inp.float32), (size, size)
19-
)
20-
result = inp.matmul(array1, array2)
21-
# print(result)
22-
23-
# original
24-
array_1 = numpy.array(array_data, dtype=numpy.float32).reshape(
25-
(size, size)
26-
)
27-
array_2 = numpy.array(array_data, dtype=numpy.float32).reshape(
28-
(size, size)
29-
)
30-
expected = numpy.matmul(array_1, array_2)
31-
# print(expected)
32-
33-
# passed
34-
numpy.testing.assert_array_equal(expected, result)
35-
# still failed
36-
# self.assertEqual(expected, result)
15+
for dtype in get_float_dtypes():
16+
# DPNP
17+
array1 = inp.reshape(
18+
inp.array(array_data, dtype=dtype), (size, size)
19+
)
20+
array2 = inp.reshape(
21+
inp.array(array_data, dtype=dtype), (size, size)
22+
)
23+
result = inp.matmul(array1, array2)
24+
# print(result)
25+
26+
# original
27+
array_1 = numpy.array(array_data, dtype=dtype).reshape((size, size))
28+
array_2 = numpy.array(array_data, dtype=dtype).reshape((size, size))
29+
expected = numpy.matmul(array_1, array_2)
30+
# print(expected)
31+
32+
# passed
33+
numpy.testing.assert_array_equal(expected, result)
34+
# still failed
35+
# self.assertEqual(expected, result)
3736

3837
def test_matmul2(self):
3938
array_data1 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
4039
array_data2 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
4140

42-
# DPNP
43-
array1 = inp.reshape(inp.array(array_data1, dtype=inp.float32), (3, 2))
44-
array2 = inp.reshape(inp.array(array_data2, dtype=inp.float32), (2, 4))
45-
result = inp.matmul(array1, array2)
46-
# print(result)
41+
for dtype in get_float_dtypes():
42+
# DPNP
43+
array1 = inp.reshape(inp.array(array_data1, dtype=dtype), (3, 2))
44+
array2 = inp.reshape(inp.array(array_data2, dtype=dtype), (2, 4))
45+
result = inp.matmul(array1, array2)
46+
# print(result)
4747

48-
# original
49-
array_1 = numpy.array(array_data1, dtype=numpy.float32).reshape((3, 2))
50-
array_2 = numpy.array(array_data2, dtype=numpy.float32).reshape((2, 4))
51-
expected = numpy.matmul(array_1, array_2)
52-
# print(expected)
48+
# original
49+
array_1 = numpy.array(array_data1, dtype=dtype).reshape((3, 2))
50+
array_2 = numpy.array(array_data2, dtype=dtype).reshape((2, 4))
51+
expected = numpy.matmul(array_1, array_2)
52+
# print(expected)
5353

54-
numpy.testing.assert_array_equal(expected, result)
54+
numpy.testing.assert_array_equal(expected, result)
5555

5656
def test_matmul3(self):
5757
array_data1 = numpy.full((513, 513), 5)
5858
array_data2 = numpy.full((513, 513), 2)
59-
out = numpy.empty((513, 513), dtype=numpy.float32)
6059

61-
# DPNP
62-
array1 = inp.array(array_data1, dtype=inp.float32)
63-
array2 = inp.array(array_data2, dtype=inp.float32)
64-
out1 = inp.array(out, dtype=inp.float32)
65-
result = inp.matmul(array1, array2, out=out1)
60+
for dtype in get_float_dtypes():
61+
out = numpy.empty((513, 513), dtype=dtype)
62+
63+
# DPNP
64+
array1 = inp.array(array_data1, dtype=dtype)
65+
array2 = inp.array(array_data2, dtype=dtype)
66+
out1 = inp.array(out, dtype=dtype)
67+
result = inp.matmul(array1, array2, out=out1)
6668

67-
# original
68-
array_1 = numpy.array(array_data1, dtype=numpy.float32)
69-
array_2 = numpy.array(array_data2, dtype=numpy.float32)
70-
expected = numpy.matmul(array_1, array_2, out=out)
69+
# original
70+
array_1 = numpy.array(array_data1, dtype=dtype)
71+
array_2 = numpy.array(array_data2, dtype=dtype)
72+
expected = numpy.matmul(array_1, array_2, out=out)
7173

72-
numpy.testing.assert_array_equal(expected, result)
74+
numpy.testing.assert_array_equal(expected, result)
7375

7476

7577
if __name__ == "__main__":

0 commit comments

Comments
 (0)