Skip to content

Commit 30287e0

Browse files
committed
fix TestElementwiseType
1 parent fb27867 commit 30287e0

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

dpnp/tests/third_party/cupy/core_tests/test_elementwise.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import pytest
55

66
import dpnp as cupy
7-
from dpnp.tests.helper import has_support_aspect64
7+
from dpnp.tests.helper import (
8+
has_support_aspect64,
9+
is_win_platform,
10+
numpy_version,
11+
)
812
from dpnp.tests.third_party.cupy import testing
913

1014

@@ -101,10 +105,13 @@ def test_large_int_upper_1(self, xp, dtype):
101105
@testing.for_int_dtypes(no_bool=True)
102106
@testing.numpy_cupy_array_equal(accept_error=OverflowError)
103107
def test_large_int_upper_2(self, xp, dtype):
104-
flag = dtype in [numpy.int16, numpy.int32, numpy.int64, numpy.longlong]
105-
flag = numpy.issubdtype(dtype, numpy.unsignedinteger) or flag
106-
if flag and numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0":
107-
pytest.skip("numpy promotes dtype differently")
108+
if numpy_version() < "2.0.0":
109+
flag = dtype in [xp.int16, xp.int32, xp.int64, xp.longlong]
110+
if xp.issubdtype(dtype, xp.unsignedinteger) or flag:
111+
pytest.skip("numpy doesn't raise OverflowError")
112+
113+
if dtype == xp.int8 and is_win_platform():
114+
pytest.skip("numpy promotes dtype differently")
108115

109116
a = xp.array([1], dtype=xp.int8)
110117
b = xp.iinfo(dtype).max - 1
@@ -115,7 +122,7 @@ def test_large_int_upper_2(self, xp, dtype):
115122
def test_large_int_upper_3(self, xp, dtype):
116123
if (
117124
numpy.issubdtype(dtype, numpy.unsignedinteger)
118-
and numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
125+
and numpy_version() < "2.0.0"
119126
):
120127
pytest.skip("numpy promotes dtype differently")
121128
elif (
@@ -133,7 +140,7 @@ def test_large_int_upper_3(self, xp, dtype):
133140
def test_large_int_upper_4(self, xp, dtype):
134141
if (
135142
numpy.issubdtype(dtype, numpy.unsignedinteger)
136-
and numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
143+
and numpy_version() < "2.0.0"
137144
):
138145
pytest.skip("numpy promotes dtype differently")
139146
elif (
@@ -149,24 +156,27 @@ def test_large_int_upper_4(self, xp, dtype):
149156
@testing.for_int_dtypes(no_bool=True)
150157
@testing.numpy_cupy_array_equal(accept_error=OverflowError)
151158
def test_large_int_lower_1(self, xp, dtype):
152-
if (
153-
dtype in [numpy.int16, numpy.int32, numpy.int64, numpy.longlong]
154-
and numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
155-
):
156-
pytest.skip("numpy promotes dtype differently")
159+
if numpy_version() < "2.0.0":
160+
if dtype in [xp.int16, xp.int32, xp.int64, xp.longlong]:
161+
pytest.skip("numpy doesn't raise OverflowError")
162+
163+
if dtype == xp.int8 and is_win_platform():
164+
pytest.skip("numpy promotes dtype differently")
157165

158166
a = xp.array([0], dtype=xp.int8)
159167
b = xp.iinfo(dtype).min
168+
res = a + b
160169
return a + b
161170

162171
@testing.for_int_dtypes(no_bool=True)
163172
@testing.numpy_cupy_array_equal(accept_error=OverflowError)
164173
def test_large_int_lower_2(self, xp, dtype):
165-
if (
166-
dtype in [numpy.int16, numpy.int32, numpy.int64, numpy.longlong]
167-
and numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
168-
):
169-
pytest.skip("numpy promotes dtype differently")
174+
if numpy_version() < "2.0.0":
175+
if dtype in [xp.int16, xp.int32, xp.int64, xp.longlong]:
176+
pytest.skip("numpy doesn't raise OverflowError")
177+
178+
if dtype == xp.int8 and is_win_platform():
179+
pytest.skip("numpy promotes dtype differently")
170180

171181
a = xp.array([-1], dtype=xp.int8)
172182
b = xp.iinfo(dtype).min + 1
@@ -177,7 +187,7 @@ def test_large_int_lower_2(self, xp, dtype):
177187
def test_large_int_lower_3(self, xp, dtype):
178188
if (
179189
numpy.issubdtype(dtype, numpy.unsignedinteger)
180-
and numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
190+
and numpy_version() < "2.0.0"
181191
):
182192
pytest.skip("numpy promotes dtype differently")
183193
elif (

0 commit comments

Comments
 (0)