44import pytest
55
66import 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+ )
812from dpnp .tests .third_party .cupy import testing
913
1014
@@ -94,20 +98,22 @@ class TestElementwiseType(unittest.TestCase):
9498 @testing .for_int_dtypes (no_bool = True )
9599 @testing .numpy_cupy_array_equal (accept_error = OverflowError )
96100 def test_large_int_upper_1 (self , xp , dtype ):
97- a = xp .array ([0 ], dtype = numpy .int8 )
101+ a = xp .array ([0 ], dtype = xp .int8 )
98102 b = xp .iinfo (dtype ).max
99103 return a + b
100104
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- if (
105- numpy .issubdtype (dtype , numpy .unsignedinteger )
106- and numpy .lib .NumpyVersion (numpy .__version__ ) < "2.0.0"
107- ):
108- 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 in [xp .int8 , xp .intc ] and is_win_platform ():
114+ pytest .skip ("numpy promotes dtype differently" )
109115
110- a = xp .array ([1 ], dtype = numpy .int8 )
116+ a = xp .array ([1 ], dtype = xp .int8 )
111117 b = xp .iinfo (dtype ).max - 1
112118 return a + b
113119
@@ -116,7 +122,7 @@ def test_large_int_upper_2(self, xp, dtype):
116122 def test_large_int_upper_3 (self , xp , dtype ):
117123 if (
118124 numpy .issubdtype (dtype , numpy .unsignedinteger )
119- and numpy . lib . NumpyVersion ( numpy . __version__ ) < "2.0.0"
125+ and numpy_version ( ) < "2.0.0"
120126 ):
121127 pytest .skip ("numpy promotes dtype differently" )
122128 elif (
@@ -134,7 +140,7 @@ def test_large_int_upper_3(self, xp, dtype):
134140 def test_large_int_upper_4 (self , xp , dtype ):
135141 if (
136142 numpy .issubdtype (dtype , numpy .unsignedinteger )
137- and numpy . lib . NumpyVersion ( numpy . __version__ ) < "2.0.0"
143+ and numpy_version ( ) < "2.0.0"
138144 ):
139145 pytest .skip ("numpy promotes dtype differently" )
140146 elif (
@@ -150,14 +156,28 @@ def test_large_int_upper_4(self, xp, dtype):
150156 @testing .for_int_dtypes (no_bool = True )
151157 @testing .numpy_cupy_array_equal (accept_error = OverflowError )
152158 def test_large_int_lower_1 (self , xp , dtype ):
153- a = xp .array ([0 ], dtype = numpy .int8 )
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 in [xp .int8 , xp .intc ] and is_win_platform ():
164+ pytest .skip ("numpy promotes dtype differently" )
165+
166+ a = xp .array ([0 ], dtype = xp .int8 )
154167 b = xp .iinfo (dtype ).min
155168 return a + b
156169
157170 @testing .for_int_dtypes (no_bool = True )
158171 @testing .numpy_cupy_array_equal (accept_error = OverflowError )
159172 def test_large_int_lower_2 (self , xp , dtype ):
160- a = xp .array ([- 1 ], dtype = numpy .int8 )
173+ if numpy_version () < "2.0.0" :
174+ if dtype in [xp .int16 , xp .int32 , xp .int64 , xp .longlong ]:
175+ pytest .skip ("numpy doesn't raise OverflowError" )
176+
177+ if dtype in [xp .int8 , xp .intc ] and is_win_platform ():
178+ pytest .skip ("numpy promotes dtype differently" )
179+
180+ a = xp .array ([- 1 ], dtype = xp .int8 )
161181 b = xp .iinfo (dtype ).min + 1
162182 return a + b
163183
@@ -166,7 +186,7 @@ def test_large_int_lower_2(self, xp, dtype):
166186 def test_large_int_lower_3 (self , xp , dtype ):
167187 if (
168188 numpy .issubdtype (dtype , numpy .unsignedinteger )
169- and numpy . lib . NumpyVersion ( numpy . __version__ ) < "2.0.0"
189+ and numpy_version ( ) < "2.0.0"
170190 ):
171191 pytest .skip ("numpy promotes dtype differently" )
172192 elif (
0 commit comments