@@ -1961,6 +1961,16 @@ def test_nin_nout(self, func, nin, nout):
19611961 {"unknown_kwarg" : 1 , "where" : False , "subok" : False },
19621962 id = "DPNPBinaryFunc" ,
19631963 ),
1964+ pytest .param (
1965+ "divmod" ,
1966+ {
1967+ "unknown_kwarg" : 1 ,
1968+ "where" : False ,
1969+ "dtype" : "?" ,
1970+ "subok" : False ,
1971+ },
1972+ id = "DPNPBinaryTwoOutputsFunc" ,
1973+ ),
19641974 ],
19651975 )
19661976 def test_not_supported_kwargs (self , func , kwargs ):
@@ -1972,23 +1982,23 @@ def test_not_supported_kwargs(self, func, kwargs):
19721982 with pytest .raises (NotImplementedError ):
19731983 fn (* args , ** {key : val })
19741984
1975- @pytest .mark .parametrize ("func" , ["abs" , "frexp" , "add" ])
1985+ @pytest .mark .parametrize ("func" , ["abs" , "frexp" , "add" , "divmod" ])
19761986 @pytest .mark .parametrize ("x" , [1 , [1 , 2 ], numpy .ones (5 )])
19771987 def test_unary_wrong_input (self , func , x ):
19781988 fn = getattr (dpnp , func )
19791989 args = [x ] * fn .nin
19801990 with pytest .raises (TypeError ):
19811991 fn (* args )
19821992
1983- @pytest .mark .parametrize ("func" , ["add" ])
1993+ @pytest .mark .parametrize ("func" , ["add" , "divmod" ])
19841994 def test_binary_wrong_input (self , func ):
19851995 x = dpnp .array ([1 , 2 , 3 ])
19861996 with pytest .raises (TypeError ):
19871997 getattr (dpnp , func )(x , [1 , 2 ])
19881998 with pytest .raises (TypeError ):
19891999 getattr (dpnp , func )([1 , 2 ], x )
19902000
1991- @pytest .mark .parametrize ("func" , ["abs" , "frexp" , "add" ])
2001+ @pytest .mark .parametrize ("func" , ["abs" , "frexp" , "add" , "divmod" ])
19922002 def test_wrong_order (self , func ):
19932003 x = dpnp .array ([1 , 2 , 3 ])
19942004
@@ -2010,7 +2020,9 @@ def test_out_dtype(self, func):
20102020 fn (* args , out = out , dtype = "f4" )
20112021
20122022 @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2013- @pytest .mark .parametrize ("func" , ["abs" , "fix" , "round" , "add" , "frexp" ])
2023+ @pytest .mark .parametrize (
2024+ "func" , ["abs" , "fix" , "round" , "add" , "frexp" , "divmod" ]
2025+ )
20142026 def test_out_wrong_tuple_len (self , xp , func ):
20152027 if func == "round" and xp is numpy :
20162028 pytest .skip ("numpy.round(x, out=(...)) is not supported" )
@@ -2033,62 +2045,87 @@ def test_out_wrong_tuple_len(self, xp, func):
20332045 _ = fn (* args , out = out )
20342046
20352047 @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2036- def test_unary_two_outs_out_ndarray (self , xp ):
2048+ @pytest .mark .parametrize ("func" , ["frexp" , "divmod" ])
2049+ def test_two_outs_out_ndarray (self , xp , func ):
20372050 x = xp .array (0.5 )
2051+
2052+ fn = getattr (xp , func )
2053+ args = [x ] * getattr (fn , "nin" , getattr (dpnp , func ).nin )
2054+
20382055 with pytest .raises (TypeError , match = "'out' must be a tuple of arrays" ):
2039- _ = xp . frexp ( x , out = xp .empty (()))
2056+ _ = fn ( * args , out = xp .empty (()))
20402057
20412058 @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2042- def test_unary_two_outs_out_mixed (self , xp ):
2059+ @pytest .mark .parametrize ("func" , ["frexp" , "divmod" ])
2060+ def test_two_outs_out_mixed (self , xp , func ):
20432061 x = xp .array (0.5 )
2062+
2063+ fn = getattr (xp , func )
2064+ args = [x ] * getattr (fn , "nin" , getattr (dpnp , func ).nin )
2065+
20442066 with pytest .raises (
20452067 TypeError ,
20462068 match = "cannot specify 'out' as both a positional and keyword" ,
20472069 ):
2048- _ = xp . frexp ( x , xp .empty (()), out = (xp .empty (()), None ))
2070+ _ = fn ( * args , xp .empty (()), out = (xp .empty (()), None ))
20492071
20502072 @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2051- def test_unary_two_outs_out_not_writable (self , xp ):
2073+ @pytest .mark .parametrize ("func" , ["frexp" , "divmod" ])
2074+ def test_two_outs_out_not_writable (self , xp , func ):
20522075 x = xp .array (0.5 )
2076+
2077+ fn = getattr (xp , func )
2078+ args = [x ] * getattr (fn , "nin" , getattr (dpnp , func ).nin )
2079+
20532080 out1 = xp .empty (())
20542081 out1 .flags ["W" ] = False
20552082
20562083 with pytest .raises (ValueError , match = "array is read-only" ):
2057- _ = xp . frexp ( x , out1 )
2084+ _ = fn ( * args , out1 )
20582085
2059- out2 = xp .empty ((), dtype = "i" )
2086+ out2 = xp .empty (())
20602087 out2 .flags ["W" ] = False
20612088 with pytest .raises (ValueError , match = "array is read-only" ):
2062- _ = xp . frexp ( x , out = (None , out2 ))
2089+ _ = fn ( * args , out = (None , out2 ))
20632090
20642091 @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2065- def test_unary_two_outs_out_wrong_shape (self , xp ):
2092+ @pytest .mark .parametrize ("func" , ["frexp" , "divmod" ])
2093+ def test_two_outs_out_wrong_shape (self , xp , func ):
20662094 x = xp .full (6 , fill_value = 0.5 )
2095+
2096+ fn = getattr (xp , func )
2097+ args = [x ] * getattr (fn , "nin" , getattr (dpnp , func ).nin )
2098+
20672099 out1 = xp .empty (12 )
20682100 with pytest .raises (ValueError ):
2069- _ = xp . frexp ( x , out1 )
2101+ _ = fn ( * args , out1 )
20702102
2071- out2 = xp .empty ((2 , 3 ), dtype = "i" )
2103+ out2 = xp .empty ((2 , 3 ))
20722104 with pytest .raises (ValueError ):
2073- _ = xp . frexp ( x , out = (None , out2 ))
2105+ _ = fn ( * args , out = (None , out2 ))
20742106
2075- def test_unary_two_outs_cfd_error (self ):
2107+ @pytest .mark .parametrize ("func" , ["frexp" , "divmod" ])
2108+ def test_unary_two_outs_cfd_error (self , func ):
20762109 x = dpnp .array (0.5 , sycl_queue = dpctl .SyclQueue ())
2110+
2111+ fn = getattr (dpnp , func )
2112+ args = [x ] * getattr (fn , "nin" , getattr (dpnp , func ).nin )
2113+
20772114 out1 = dpnp .empty ((), sycl_queue = dpctl .SyclQueue ())
20782115 out2 = dpnp .empty ((), sycl_queue = dpctl .SyclQueue ())
20792116 with pytest .raises (
20802117 ExecutionPlacementError ,
20812118 match = "Input and output allocation queues are not compatible" ,
20822119 ):
2083- _ = dpnp . frexp ( x , out1 )
2120+ _ = fn ( * args , out1 )
20842121
20852122 with pytest .raises (
20862123 ExecutionPlacementError ,
20872124 match = "Input and output allocation queues are not compatible" ,
20882125 ):
2089- _ = dpnp . frexp ( x , out = (None , out2 ))
2126+ _ = fn ( * args , out = (None , out2 ))
20902127
2091- @pytest .mark .parametrize ("func" , ["abs" , "frexp" , "add" ])
2128+ @pytest .mark .parametrize ("func" , ["abs" , "frexp" , "add" , "divmod" ])
20922129 @pytest .mark .parametrize ("order" , [None , "K" , "A" , "f" , "c" ])
20932130 def test_order (self , func , order ):
20942131 a = numpy .array ([1 , 2 , 3 ])
0 commit comments