Skip to content

Commit 74bbc96

Browse files
Update test_mixins
1 parent 165631c commit 74bbc96

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

tests/test_mixins.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
from .helper import skip_or_change_if_dtype_not_supported
23

34
import dpnp as inp
45

@@ -7,19 +8,25 @@
78

89
class TestMatMul(unittest.TestCase):
910

11+
@classmethod
12+
def setUpClass(cls):
13+
cls.dtype = skip_or_change_if_dtype_not_supported(
14+
inp.float64, change_dtype=True
15+
)
16+
1017
def test_matmul(self):
1118
array_data = [1., 2., 3., 4.]
1219
size = 2
1320

1421
# DPNP
15-
array1 = inp.reshape(inp.array(array_data, dtype=inp.float64), (size, size))
16-
array2 = inp.reshape(inp.array(array_data, dtype=inp.float64), (size, size))
22+
array1 = inp.reshape(inp.array(array_data, dtype=self.dtype), (size, size))
23+
array2 = inp.reshape(inp.array(array_data, dtype=self.dtype), (size, size))
1724
result = inp.matmul(array1, array2)
1825
# print(result)
1926

2027
# original
21-
array_1 = numpy.array(array_data, dtype=numpy.float64).reshape((size, size))
22-
array_2 = numpy.array(array_data, dtype=numpy.float64).reshape((size, size))
28+
array_1 = numpy.array(array_data, dtype=self.dtype).reshape((size, size))
29+
array_2 = numpy.array(array_data, dtype=self.dtype).reshape((size, size))
2330
expected = numpy.matmul(array_1, array_2)
2431
# print(expected)
2532

@@ -33,14 +40,14 @@ def test_matmul2(self):
3340
array_data2 = [1., 2., 3., 4., 5., 6., 7., 8.]
3441

3542
# DPNP
36-
array1 = inp.reshape(inp.array(array_data1, dtype=inp.float64), (3, 2))
37-
array2 = inp.reshape(inp.array(array_data2, dtype=inp.float64), (2, 4))
43+
array1 = inp.reshape(inp.array(array_data1, dtype=self.dtype), (3, 2))
44+
array2 = inp.reshape(inp.array(array_data2, dtype=self.dtype), (2, 4))
3845
result = inp.matmul(array1, array2)
3946
# print(result)
4047

4148
# original
42-
array_1 = numpy.array(array_data1, dtype=numpy.float64).reshape((3, 2))
43-
array_2 = numpy.array(array_data2, dtype=numpy.float64).reshape((2, 4))
49+
array_1 = numpy.array(array_data1, dtype=self.dtype).reshape((3, 2))
50+
array_2 = numpy.array(array_data2, dtype=self.dtype).reshape((2, 4))
4451
expected = numpy.matmul(array_1, array_2)
4552
# print(expected)
4653

@@ -49,17 +56,17 @@ def test_matmul2(self):
4956
def test_matmul3(self):
5057
array_data1 = numpy.full((513, 513), 5)
5158
array_data2 = numpy.full((513, 513), 2)
52-
out = numpy.empty((513, 513), dtype=numpy.float64)
59+
out = numpy.empty((513, 513), dtype=self.dtype)
5360

5461
# DPNP
55-
array1 = inp.array(array_data1, dtype=inp.float64)
56-
array2 = inp.array(array_data2, dtype=inp.float64)
57-
out1 = inp.array(out, dtype=inp.float64)
62+
array1 = inp.array(array_data1, dtype=self.dtype)
63+
array2 = inp.array(array_data2, dtype=self.dtype)
64+
out1 = inp.array(out, dtype=self.dtype)
5865
result = inp.matmul(array1, array2, out=out1)
5966

6067
# original
61-
array_1 = numpy.array(array_data1, dtype=numpy.float64)
62-
array_2 = numpy.array(array_data2, dtype=numpy.float64)
68+
array_1 = numpy.array(array_data1, dtype=self.dtype)
69+
array_2 = numpy.array(array_data2, dtype=self.dtype)
6370
expected = numpy.matmul(array_1, array_2, out=out)
6471

6572
numpy.testing.assert_array_equal(expected, result)

0 commit comments

Comments
 (0)