Skip to content

Commit 92e9b1c

Browse files
vtavanaantonwolfy
andauthored
Modify the tests to align them with the changes in dpctl (#1527)
Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com>
1 parent ab97cf3 commit 92e9b1c

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

tests/test_mathematical.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def test_invalid_shape(self, shape, dtype):
633633
dp_array = dpnp.arange(10, dtype=dtype)
634634
dp_out = dpnp.empty(shape, dtype=dtype)
635635

636-
with pytest.raises(TypeError):
636+
with pytest.raises(ValueError):
637637
dpnp.ceil(dp_array, out=dp_out)
638638

639639

@@ -673,7 +673,7 @@ def test_invalid_shape(self, shape, dtype):
673673
dp_array = dpnp.arange(10, dtype=dtype)
674674
dp_out = dpnp.empty(shape, dtype=dtype)
675675

676-
with pytest.raises(TypeError):
676+
with pytest.raises(ValueError):
677677
dpnp.floor(dp_array, out=dp_out)
678678

679679

@@ -713,7 +713,7 @@ def test_invalid_shape(self, shape, dtype):
713713
dp_array = dpnp.arange(10, dtype=dtype)
714714
dp_out = dpnp.empty(shape, dtype=dtype)
715715

716-
with pytest.raises(TypeError):
716+
with pytest.raises(ValueError):
717717
dpnp.trunc(dp_array, out=dp_out)
718718

719719

@@ -765,9 +765,15 @@ def test_out_dtypes(self, dtype):
765765
@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True))
766766
def test_out_overlap(self, dtype):
767767
size = 1 if dtype == dpnp.bool else 15
768+
# DPNP
768769
dp_a = dpnp.arange(2 * size, dtype=dtype)
769-
with pytest.raises(TypeError):
770-
dpnp.add(dp_a[size::], dp_a[::2], out=dp_a[:size:])
770+
dpnp.add(dp_a[size::], dp_a[::2], out=dp_a[:size:])
771+
772+
# original
773+
np_a = numpy.arange(2 * size, dtype=dtype)
774+
numpy.add(np_a[size::], np_a[::2], out=np_a[:size:])
775+
776+
assert_allclose(np_a, dp_a)
771777

772778
@pytest.mark.parametrize(
773779
"dtype", get_all_dtypes(no_bool=True, no_none=True)
@@ -791,7 +797,7 @@ def test_invalid_shape(self, shape):
791797
dp_array2 = dpnp.arange(5, 15)
792798
dp_out = dpnp.empty(shape)
793799

794-
with pytest.raises(TypeError):
800+
with pytest.raises(ValueError):
795801
dpnp.add(dp_array1, dp_array2, out=dp_out)
796802

797803
@pytest.mark.parametrize(
@@ -854,9 +860,15 @@ def test_out_dtypes(self, dtype):
854860
@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True))
855861
def test_out_overlap(self, dtype):
856862
size = 1 if dtype == dpnp.bool else 15
863+
# DPNP
857864
dp_a = dpnp.arange(2 * size, dtype=dtype)
858-
with pytest.raises(TypeError):
859-
dpnp.multiply(dp_a[size::], dp_a[::2], out=dp_a[:size:])
865+
dpnp.multiply(dp_a[size::], dp_a[::2], out=dp_a[:size:])
866+
867+
# original
868+
np_a = numpy.arange(2 * size, dtype=dtype)
869+
numpy.multiply(np_a[size::], np_a[::2], out=np_a[:size:])
870+
871+
assert_allclose(np_a, dp_a)
860872

861873
@pytest.mark.parametrize(
862874
"dtype", get_all_dtypes(no_bool=True, no_none=True)
@@ -880,7 +892,7 @@ def test_invalid_shape(self, shape):
880892
dp_array2 = dpnp.arange(5, 15)
881893
dp_out = dpnp.empty(shape)
882894

883-
with pytest.raises(TypeError):
895+
with pytest.raises(ValueError):
884896
dpnp.multiply(dp_array1, dp_array2, out=dp_out)
885897

886898
@pytest.mark.parametrize(

tests/test_umath.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def test_invalid_shape(self, shape):
171171
dp_array = dpnp.arange(10)
172172
dp_out = dpnp.empty(shape, dtype=dp_array.dtype)
173173

174-
with pytest.raises(TypeError):
174+
with pytest.raises(ValueError):
175175
dpnp.sin(dp_array, out=dp_out)
176176

177177

@@ -254,7 +254,7 @@ def test_invalid_shape(self, shape):
254254
dp_array = dpnp.arange(10)
255255
dp_out = dpnp.empty(shape, dtype=dp_array.dtype)
256256

257-
with pytest.raises(TypeError):
257+
with pytest.raises(ValueError):
258258
dpnp.cos(dp_array, out=dp_out)
259259

260260

@@ -337,7 +337,7 @@ def test_invalid_shape(self, shape):
337337
dp_array = dpnp.arange(10)
338338
dp_out = dpnp.empty(shape, dtype=dp_array.dtype)
339339

340-
with pytest.raises(TypeError):
340+
with pytest.raises(ValueError):
341341
dpnp.log(dp_array, out=dp_out)
342342

343343

@@ -613,7 +613,7 @@ def test_invalid_shape(self, shape):
613613
dp_array = dpnp.arange(10, dtype=dpnp.float32)
614614
dp_out = dpnp.empty(shape, dtype=dpnp.float32)
615615

616-
with pytest.raises(TypeError):
616+
with pytest.raises(ValueError):
617617
dpnp.sqrt(dp_array, out=dp_out)
618618

619619
@pytest.mark.parametrize(
@@ -675,7 +675,7 @@ def test_invalid_shape(self, shape):
675675
dp_array = dpnp.arange(10, dtype=dpnp.float32)
676676
dp_out = dpnp.empty(shape, dtype=dpnp.float32)
677677

678-
with pytest.raises(TypeError):
678+
with pytest.raises(ValueError):
679679
dpnp.square(dp_array, out=dp_out)
680680

681681
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)