@@ -802,12 +802,6 @@ def test_strides_out(self, stride, dt):
802802 assert_array_equal (iout_mant , out_mant )
803803 assert_array_equal (iout_exp , out_exp )
804804
805- @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
806- def test_out_wrong_type (self , xp ):
807- a = xp .array (0.5 )
808- with pytest .raises (TypeError , match = "'out' must be a tuple of arrays" ):
809- _ = xp .frexp (a , out = xp .empty (()))
810-
811805 @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
812806 @pytest .mark .parametrize ("dt" , get_complex_dtypes ())
813807 def test_complex_dtype (self , xp , dt ):
@@ -2080,7 +2074,7 @@ def test_not_supported_kwargs(self, func, kwargs):
20802074
20812075 @pytest .mark .parametrize ("func" , ["abs" , "frexp" , "add" ])
20822076 @pytest .mark .parametrize ("x" , [1 , [1 , 2 ], numpy .ones (5 )])
2083- def test_wrong_input (self , func , x ):
2077+ def test_unary_wrong_input (self , func , x ):
20842078 fn = getattr (dpnp , func )
20852079 args = [x ] * fn .nin
20862080 with pytest .raises (TypeError ):
@@ -2115,8 +2109,62 @@ def test_out_dtype(self, func):
21152109 ):
21162110 fn (* args , out = out , dtype = "f4" )
21172111
2112+ @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2113+ def test_unary_two_outs_out_ndarray (self , xp ):
2114+ x = xp .array (0.5 )
2115+ with pytest .raises (TypeError , match = "'out' must be a tuple of arrays" ):
2116+ _ = xp .frexp (x , out = xp .empty (()))
2117+
2118+ @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2119+ @pytest .mark .parametrize ("out" , [(), (1 ,), (1 , 2 , 3 )])
2120+ def test_unary_two_outs_out_wrong_tuple_len (self , xp , out ):
2121+ x = xp .array (0.5 )
2122+ with pytest .raises (
2123+ ValueError ,
2124+ match = "'out' tuple must have exactly one entry per ufunc output" ,
2125+ ):
2126+ _ = xp .frexp (x , out = out )
2127+
2128+ @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2129+ def test_unary_two_outs_out_mixed (self , xp ):
2130+ x = xp .array (0.5 )
2131+ with pytest .raises (
2132+ TypeError ,
2133+ match = "cannot specify 'out' as both a positional and keyword" ,
2134+ ):
2135+ _ = xp .frexp (x , xp .empty (()), out = (xp .empty (()), None ))
2136+
2137+ @pytest .mark .parametrize ("func" , ["abs" , "add" ])
2138+ @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2139+ def test_unary_two_outs_out_not_writable (self , func , xp ):
2140+ x = xp .array (0.5 )
2141+ out1 = xp .empty (())
2142+ out1 .flags ["W" ] = False
2143+
2144+ fn = getattr (xp , func )
2145+ args = [x ] * fn .nin
2146+ with pytest .raises (ValueError , match = "array is read-only" ):
2147+ _ = fn (* args , out1 )
2148+
2149+ out2 = xp .empty ((), dtype = "i" )
2150+ out2 .flags ["W" ] = False
2151+ with pytest .raises (ValueError , match = "array is read-only" ):
2152+ _ = fn (* args , out = (None , out2 ))
2153+
2154+ @pytest .mark .parametrize ("xp" , [numpy , dpnp ])
2155+ def test_unary_two_outs_out_wrong_shape (self , xp ):
2156+ x = xp .full (6 , fill_value = 0.5 )
2157+ out1 = xp .empty (12 )
2158+ with pytest .raises (ValueError ):
2159+ _ = xp .frexp (x , out1 )
2160+
2161+ out2 = xp .empty ((2 , 3 ), dtype = "i" )
2162+ with pytest .raises (ValueError ):
2163+ _ = xp .frexp (x , out = (None , out2 ))
2164+
21182165 @pytest .mark .parametrize ("func" , ["abs" , "frexp" , "add" ])
2119- def test_order_none (self , func ):
2166+ @pytest .mark .parametrize ("order" , [None , "K" , "A" , "f" , "c" ])
2167+ def test_order (self , func , order ):
21202168 a = numpy .array ([1 , 2 , 3 ])
21212169 ia = dpnp .array (a )
21222170
@@ -2126,8 +2174,8 @@ def test_order_none(self, func):
21262174 args = [a ] * fn .nin
21272175 iargs = [ia ] * ifn .nin
21282176
2129- result = ifn (* iargs , order = None )
2130- expected = fn (* args , order = None )
2177+ result = ifn (* iargs , order = order )
2178+ expected = fn (* args , order = order )
21312179 if fn .nout == 1 :
21322180 assert_dtype_allclose (result , expected )
21332181 else :
0 commit comments