66import pytest
77
88import dpnp as cupy
9+ from tests .helper import has_support_aspect64
910from tests .third_party .cupy import testing
1011
1112
@@ -60,7 +61,7 @@ def test_arange9(self):
6061 def test_arange_no_dtype_int (self , xp ):
6162 return xp .arange (1 , 11 , 2 )
6263
63- @testing .numpy_cupy_array_equal ( )
64+ @testing .numpy_cupy_allclose ( rtol = 1e-4 , type_check = has_support_aspect64 () )
6465 def test_arange_no_dtype_float (self , xp ):
6566 return xp .arange (1.0 , 11.0 , 2.0 )
6667
@@ -120,11 +121,11 @@ def test_linspace_with_retstep(self, xp, dtype):
120121 self .assertEqual (step , 2.5 )
121122 return x
122123
123- @testing .numpy_cupy_allclose ()
124+ @testing .numpy_cupy_allclose (rtol = 1e-4 , type_check = has_support_aspect64 () )
124125 def test_linspace_no_dtype_int (self , xp ):
125126 return xp .linspace (0 , 10 , 50 )
126127
127- @testing .numpy_cupy_allclose ()
128+ @testing .numpy_cupy_allclose (rtol = 1e-4 , type_check = has_support_aspect64 () )
128129 def test_linspace_no_dtype_float (self , xp ):
129130 return xp .linspace (0.0 , 10.0 , 50 )
130131
@@ -139,21 +140,23 @@ def test_linspace_neg_num(self):
139140
140141 @testing .numpy_cupy_allclose ()
141142 def test_linspace_float_overflow (self , xp ):
142- return xp .linspace (0.0 , sys .float_info .max / 5 , 10 , dtype = float )
143+ dtype = cupy .default_float_type ()
144+ return xp .linspace (0.0 , numpy .finfo (dtype ).max / 5 , 10 , dtype = dtype )
143145
144- @testing .numpy_cupy_array_equal ()
146+ @testing .numpy_cupy_allclose ()
145147 def test_linspace_float_underflow (self , xp ):
146148 # find minimum subnormal number
147- x = sys .float_info .min
149+ dtype = cupy .default_float_type ()
150+ x = numpy .finfo (dtype ).min
148151 while x / 2 > 0 :
149152 x /= 2
150- return xp .linspace (0.0 , x , 10 , dtype = float )
153+ return xp .linspace (0.0 , x , 10 , dtype = dtype )
151154
152155 @testing .with_requires ("numpy>=1.16" )
153156 @testing .for_all_dtypes_combination (
154157 names = ("dtype_range" , "dtype_out" ), no_bool = True , no_complex = True
155158 )
156- @testing .numpy_cupy_allclose ()
159+ @testing .numpy_cupy_allclose (rtol = 1e-04 )
157160 def test_linspace_array_start_stop (self , xp , dtype_range , dtype_out ):
158161 start = xp .array ([0 , 120 ], dtype = dtype_range )
159162 stop = xp .array ([100 , 0 ], dtype = dtype_range )
@@ -163,7 +166,7 @@ def test_linspace_array_start_stop(self, xp, dtype_range, dtype_out):
163166 @testing .for_all_dtypes_combination (
164167 names = ("dtype_range" , "dtype_out" ), no_bool = True , no_complex = True
165168 )
166- @testing .numpy_cupy_array_equal ( )
169+ @testing .numpy_cupy_allclose ( rtol = 1e-04 )
167170 def test_linspace_mixed_start_stop (self , xp , dtype_range , dtype_out ):
168171 start = 0.0
169172 if xp .dtype (dtype_range ).kind in "u" :
@@ -176,7 +179,7 @@ def test_linspace_mixed_start_stop(self, xp, dtype_range, dtype_out):
176179 @testing .for_all_dtypes_combination (
177180 names = ("dtype_range" , "dtype_out" ), no_bool = True , no_complex = True
178181 )
179- @testing .numpy_cupy_allclose ()
182+ @testing .numpy_cupy_allclose (rtol = 1e-04 )
180183 def test_linspace_mixed_start_stop2 (self , xp , dtype_range , dtype_out ):
181184 if xp .dtype (dtype_range ).kind in "u" :
182185 start = xp .array ([160 , 120 ], dtype = dtype_range )
@@ -205,7 +208,7 @@ def test_linspace_complex_start_stop(self, xp, dtype):
205208
206209 @testing .with_requires ("numpy>=1.16" )
207210 @testing .for_all_dtypes (no_bool = True )
208- @testing .numpy_cupy_array_equal ( )
211+ @testing .numpy_cupy_allclose ( rtol = 1e-04 )
209212 def test_linspace_start_stop_list (self , xp , dtype ):
210213 start = [0 , 0 ]
211214 stop = [100 , 16 ]
@@ -241,12 +244,12 @@ def test_logspace_no_endpoint(self, xp, dtype):
241244 return xp .logspace (0 , 2 , 5 , dtype = dtype , endpoint = False )
242245
243246 @pytest .mark .usefixtures ("allow_fall_back_on_numpy" )
244- @testing .numpy_cupy_allclose ()
247+ @testing .numpy_cupy_allclose (rtol = 1e-4 , type_check = has_support_aspect64 () )
245248 def test_logspace_no_dtype_int (self , xp ):
246249 return xp .logspace (0 , 2 )
247250
248251 @pytest .mark .usefixtures ("allow_fall_back_on_numpy" )
249- @testing .numpy_cupy_allclose ()
252+ @testing .numpy_cupy_allclose (rtol = 1e-4 , type_check = has_support_aspect64 () )
250253 def test_logspace_no_dtype_float (self , xp ):
251254 return xp .logspace (0.0 , 2.0 )
252255
@@ -262,7 +265,7 @@ def test_logspace_neg_num(self):
262265
263266 @pytest .mark .usefixtures ("allow_fall_back_on_numpy" )
264267 @testing .for_all_dtypes (no_bool = True )
265- @testing .numpy_cupy_allclose ()
268+ @testing .numpy_cupy_allclose (rtol = 1e-04 )
266269 def test_logspace_base (self , xp , dtype ):
267270 return xp .logspace (0 , 2 , 5 , base = 2.0 , dtype = dtype )
268271
@@ -323,7 +326,7 @@ def test_mgrid0(self, xp):
323326 def test_mgrid1 (self , xp ):
324327 return xp .mgrid [- 10 :10 ]
325328
326- @testing .numpy_cupy_array_equal ( )
329+ @testing .numpy_cupy_allclose ( rtol = 1e-4 , type_check = has_support_aspect64 () )
327330 def test_mgrid2 (self , xp ):
328331 return xp .mgrid [- 10 :10 :10j ]
329332
@@ -333,7 +336,7 @@ def test_mgrid3(self, xp):
333336 y = xp .ones (10 )[:, None ]
334337 return xp .mgrid [x :y :10j ]
335338
336- @testing .numpy_cupy_array_equal ( )
339+ @testing .numpy_cupy_allclose ( rtol = 1e-4 , type_check = has_support_aspect64 () )
337340 def test_mgrid4 (self , xp ):
338341 # check len(keys) > 1
339342 return xp .mgrid [- 10 :10 :10j , - 10 :10 :10j ]
@@ -356,7 +359,7 @@ def test_ogrid0(self, xp):
356359 def test_ogrid1 (self , xp ):
357360 return xp .ogrid [- 10 :10 ]
358361
359- @testing .numpy_cupy_array_equal ( )
362+ @testing .numpy_cupy_allclose ( rtol = 1e-4 , type_check = has_support_aspect64 () )
360363 def test_ogrid2 (self , xp ):
361364 return xp .ogrid [- 10 :10 :10j ]
362365
0 commit comments