1919 get_float_dtypes ,
2020 has_support_aspect16 ,
2121 has_support_aspect64 ,
22+ is_gpu_device ,
2223)
2324
2425# full list of umaths
2526umaths = [i for i in dir (numpy ) if isinstance (getattr (numpy , i ), numpy .ufunc )]
2627
27- types = {
28- "d" : numpy .float64 ,
29- "f" : numpy .float32 ,
30- "l" : numpy .int64 ,
31- "i" : numpy .int32 ,
32- }
33-
34- supported_types = "fli"
28+ supported_types = "?bBhHiIlLkK"
29+ if has_support_aspect16 ():
30+ supported_types += "e"
31+ supported_types += "fF"
3532if has_support_aspect64 ():
36- supported_types += "d "
33+ supported_types += "dD "
3734
3835
3936def check_types (args_str ):
@@ -54,7 +51,7 @@ def shaped_arange(shape, xp=numpy, dtype=numpy.float32):
5451def get_args (args_str , sh , xp = numpy ):
5552 args = []
5653 for s in args_str :
57- args .append (shaped_arange (shape = sh , xp = xp , dtype = types [ s ] ))
54+ args .append (shaped_arange (shape = sh , xp = xp , dtype = numpy . dtype ( s ) ))
5855 return tuple (args )
5956
6057
@@ -74,6 +71,7 @@ def get_id(val):
7471 return val .__str__ ()
7572
7673
74+ @pytest .mark .filterwarnings ("ignore:overflow encountered:RuntimeWarning" )
7775@pytest .mark .usefixtures ("suppress_divide_invalid_numpy_warnings" )
7876@pytest .mark .parametrize ("test_cases" , test_cases , ids = get_id )
7977def test_umaths (test_cases ):
@@ -90,7 +88,7 @@ def test_umaths(test_cases):
9088 iargs = get_args (args_str , sh , xp = dpnp )
9189
9290 if umath == "reciprocal" :
93- if args [0 ].dtype in [ numpy . int32 , numpy .int64 ] :
91+ if numpy . issubdtype ( args [0 ].dtype , numpy .integer ) :
9492 pytest .skip (
9593 "For integer input array, numpy.reciprocal returns zero."
9694 )
@@ -101,11 +99,21 @@ def test_umaths(test_cases):
10199 and numpy .dtype ("l" ) != numpy .int64
102100 ):
103101 pytest .skip ("numpy.ldexp doesn't have a loop for the input types" )
102+ elif (
103+ umath == "floor_divide"
104+ and args [0 ].dtype in [dpnp .float16 , dpnp .float32 ]
105+ and is_gpu_device ()
106+ ):
107+ pytest .skip ("dpctl-1652" )
108+ elif umath in ["divmod" , "frexp" ]:
109+ pytest .skip ("Not implemented umath" )
110+ elif umath == "modf" and args [0 ].dtype == dpnp .float16 :
111+ pytest .skip ("dpnp.modf is not supported with dpnp.float16" )
104112
105113 expected = getattr (numpy , umath )(* args )
106114 result = getattr (dpnp , umath )(* iargs )
107-
108- assert_allclose ( result , expected , rtol = 1e-6 )
115+ for x , y in zip ( result , expected ):
116+ assert_dtype_allclose ( x , y )
109117
110118
111119def _get_output_data_type (dtype ):
0 commit comments