2020 get_float_dtypes ,
2121 has_support_aspect16 ,
2222 has_support_aspect64 ,
23+ is_gpu_device ,
2324)
2425
2526# full list of umaths
2627umaths = [i for i in dir (numpy ) if isinstance (getattr (numpy , i ), numpy .ufunc )]
2728
28- types = {
29- "d" : numpy .float64 ,
30- "f" : numpy .float32 ,
31- "l" : numpy .int64 ,
32- "i" : numpy .int32 ,
33- }
34-
35- supported_types = "fli"
29+ supported_types = "?bBhHiIlLkK"
30+ if has_support_aspect16 ():
31+ supported_types += "e"
32+ supported_types += "fF"
3633if has_support_aspect64 ():
37- supported_types += "d "
34+ supported_types += "dD "
3835
3936
4037def check_types (args_str ):
@@ -55,7 +52,7 @@ def shaped_arange(shape, xp=numpy, dtype=numpy.float32):
5552def get_args (args_str , sh , xp = numpy ):
5653 args = []
5754 for s in args_str :
58- args .append (shaped_arange (shape = sh , xp = xp , dtype = types [ s ] ))
55+ args .append (shaped_arange (shape = sh , xp = xp , dtype = numpy . dtype ( s ) ))
5956 return tuple (args )
6057
6158
@@ -75,6 +72,7 @@ def get_id(val):
7572 return val .__str__ ()
7673
7774
75+ @pytest .mark .filterwarnings ("ignore:overflow encountered:RuntimeWarning" )
7876@pytest .mark .usefixtures ("suppress_divide_invalid_numpy_warnings" )
7977@pytest .mark .parametrize ("test_cases" , test_cases , ids = get_id )
8078def test_umaths (test_cases ):
@@ -91,7 +89,7 @@ def test_umaths(test_cases):
9189 iargs = get_args (args_str , sh , xp = dpnp )
9290
9391 if umath == "reciprocal" :
94- if args [0 ].dtype in [ numpy . int32 , numpy .int64 ] :
92+ if numpy . issubdtype ( args [0 ].dtype , numpy .integer ) :
9593 pytest .skip (
9694 "For integer input array, numpy.reciprocal returns zero."
9795 )
@@ -102,11 +100,21 @@ def test_umaths(test_cases):
102100 and numpy .dtype ("l" ) != numpy .int64
103101 ):
104102 pytest .skip ("numpy.ldexp doesn't have a loop for the input types" )
103+ elif (
104+ umath == "floor_divide"
105+ and args [0 ].dtype in [dpnp .float16 , dpnp .float32 ]
106+ and is_gpu_device ()
107+ ):
108+ pytest .skip ("dpctl-1652" )
109+ elif umath in ["divmod" , "frexp" ]:
110+ pytest .skip ("Not implemented umath" )
111+ elif umath == "modf" and args [0 ].dtype == dpnp .float16 :
112+ pytest .skip ("dpnp.modf is not supported with dpnp.float16" )
105113
106114 expected = getattr (numpy , umath )(* args )
107115 result = getattr (dpnp , umath )(* iargs )
108-
109- assert_allclose ( result , expected , rtol = 1e-6 )
116+ for x , y in zip ( result , expected ):
117+ assert_dtype_allclose ( x , y )
110118
111119
112120class TestArctan2 :
0 commit comments