Skip to content

Commit 0dd79c0

Browse files
committed
update more tests
1 parent 48bc9bd commit 0dd79c0

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

tests/test_mathematical.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ def test_invalid_dtype(self, dtype):
11601160
dp_array = dpnp.arange(10, dtype=dpnp_dtype)
11611161
dp_out = dpnp.empty(10, dtype=dtype)
11621162

1163-
with pytest.raises(TypeError):
1163+
with pytest.raises(ValueError):
11641164
dpnp.ceil(dp_array, out=dp_out)
11651165

11661166
@pytest.mark.parametrize("dtype", get_float_dtypes())
@@ -1200,7 +1200,7 @@ def test_invalid_dtype(self, dtype):
12001200
dp_array = dpnp.arange(10, dtype=dpnp_dtype)
12011201
dp_out = dpnp.empty(10, dtype=dtype)
12021202

1203-
with pytest.raises(TypeError):
1203+
with pytest.raises(ValueError):
12041204
dpnp.floor(dp_array, out=dp_out)
12051205

12061206
@pytest.mark.parametrize("dtype", get_float_dtypes())
@@ -1240,7 +1240,7 @@ def test_invalid_dtype(self, dtype):
12401240
dp_array = dpnp.arange(10, dtype=dpnp_dtype)
12411241
dp_out = dpnp.empty(10, dtype=dtype)
12421242

1243-
with pytest.raises(TypeError):
1243+
with pytest.raises(ValueError):
12441244
dpnp.trunc(dp_array, out=dp_out)
12451245

12461246
@pytest.mark.parametrize("dtype", get_float_dtypes())
@@ -1291,7 +1291,7 @@ def test_out_dtypes(self, dtype):
12911291
dp_out = dpnp.empty(size, dtype=dpnp.complex64)
12921292
if dtype != dpnp.complex64:
12931293
# dtype of out mismatches types of input arrays
1294-
with pytest.raises(TypeError):
1294+
with pytest.raises(ValueError):
12951295
dpnp.add(dp_array1, dp_array2, out=dp_out)
12961296

12971297
# allocate new out with expected type
@@ -1388,7 +1388,7 @@ def test_out_dtypes(self, dtype):
13881388
check_dtype = True
13891389
if dtype != dpnp.complex64:
13901390
# dtype of out mismatches types of input arrays
1391-
with pytest.raises(TypeError):
1391+
with pytest.raises(ValueError):
13921392
dpnp.divide(dp_array1, dp_array2, out=dp_out)
13931393

13941394
# allocate new out with expected type
@@ -1489,7 +1489,7 @@ def test_out_dtypes(self, dtype):
14891489
dp_out = dpnp.empty(size, dtype=dpnp.complex64)
14901490
if dtype != dpnp.complex64:
14911491
# dtype of out mismatches types of input arrays
1492-
with pytest.raises(TypeError):
1492+
with pytest.raises(ValueError):
14931493
dpnp.floor_divide(dp_array1, dp_array2, out=dp_out)
14941494

14951495
# allocate new out with expected type
@@ -1917,7 +1917,7 @@ def test_out_dtypes(self, dtype):
19171917
dp_out = dpnp.empty(size, dtype=dpnp.complex64)
19181918
if dtype != dpnp.complex64:
19191919
# dtype of out mismatches types of input arrays
1920-
with pytest.raises(TypeError):
1920+
with pytest.raises(ValueError):
19211921
dpnp.maximum(dp_array1, dp_array2, out=dp_out)
19221922

19231923
# allocate new out with expected type
@@ -1998,7 +1998,7 @@ def test_out_dtypes(self, dtype):
19981998
dp_out = dpnp.empty(size, dtype=dpnp.complex64)
19991999
if dtype != dpnp.complex64:
20002000
# dtype of out mismatches types of input arrays
2001-
with pytest.raises(TypeError):
2001+
with pytest.raises(ValueError):
20022002
dpnp.minimum(dp_array1, dp_array2, out=dp_out)
20032003

20042004
# allocate new out with expected type
@@ -2079,7 +2079,7 @@ def test_out_dtypes(self, dtype):
20792079
dp_out = dpnp.empty(size, dtype=dpnp.complex64)
20802080
if dtype != dpnp.complex64:
20812081
# dtype of out mismatches types of input arrays
2082-
with pytest.raises(TypeError):
2082+
with pytest.raises(ValueError):
20832083
dpnp.multiply(dp_array1, dp_array2, out=dp_out)
20842084

20852085
# allocate new out with expected type
@@ -2174,7 +2174,7 @@ def test_out_dtypes(self, dtype):
21742174
dp_out = dpnp.empty(size, dtype=dpnp.complex64)
21752175
if dtype != dpnp.complex64:
21762176
# dtype of out mismatches types of input arrays
2177-
with pytest.raises(TypeError):
2177+
with pytest.raises(ValueError):
21782178
dpnp.power(dp_array1, dp_array2, out=dp_out)
21792179

21802180
# allocate new out with expected type

tests/third_party/cupy/core_tests/test_ndarray_unary_op.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ def test_invert_array(self):
124124
@testing.numpy_cupy_allclose(accept_error=TypeError)
125125
def check_zerodim_op(self, op, xp, dtype):
126126
a = xp.array(-2).astype(dtype)
127-
return op(a)
127+
if op == operator.invert and numpy.issubdtype(dtype, numpy.inexact):
128+
# NumPy returns TypeError
129+
# DPNP returns ValueError
130+
pytest.skip("NumPy and DPNP returns different types of error.")
131+
else:
132+
return op(a)
128133

129134
def test_invert_zerodim(self):
130135
self.check_zerodim_op(operator.invert)

tests/third_party/cupy/math_tests/test_rounding.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from tests.third_party.cupy import testing
99

1010

11-
@testing.gpu
1211
class TestRounding(unittest.TestCase):
1312
@testing.for_all_dtypes(no_complex=True)
1413
@testing.numpy_cupy_allclose(type_check=False, atol=1e-5)
@@ -26,7 +25,11 @@ def check_unary_complex(self, name, xp, dtype):
2625
def check_unary_complex_unsupported(self, name, dtype):
2726
for xp in (numpy, cupy):
2827
a = testing.shaped_arange((2, 3), xp, dtype)
29-
with pytest.raises(TypeError):
28+
if xp == cupy and name in ["ceil", "floor", "trunc"]:
29+
Error = ValueError
30+
else:
31+
Error = TypeError
32+
with pytest.raises(Error):
3033
getattr(xp, name)(a)
3134

3235
@testing.for_dtypes(["?", "b", "h", "i", "q", "e", "f", "d"])

0 commit comments

Comments
 (0)