@@ -87,6 +87,21 @@ def test_inplace_dtype(self, dtype1, dtype2):
87
87
with pytest .raises (ValueError ):
88
88
ia += ib
89
89
90
+ @pytest .mark .parametrize ("dtype1" , ALL_DTYPES )
91
+ @pytest .mark .parametrize ("dtype2" , ALL_DTYPES )
92
+ def test_inplace_dtype_explicit (self , dtype1 , dtype2 ):
93
+ a = numpy .array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
94
+ b = numpy .array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
95
+ ia , ib = dpnp .array (a ), dpnp .array (b )
96
+
97
+ if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
98
+ result = dpnp .add (ia , ib , out = ia )
99
+ expected = numpy .add (a , b , out = a )
100
+ assert_dtype_allclose (result , expected )
101
+ else :
102
+ assert_raises (TypeError , numpy .add , a , b , out = a )
103
+ assert_raises (ValueError , dpnp .add , ia , ib , out = ia )
104
+
90
105
@pytest .mark .parametrize ("shape" , [(0 ,), (15 ,), (2 , 2 )])
91
106
def test_invalid_shape (self , shape ):
92
107
a , b = dpnp .arange (10 ), dpnp .arange (10 )
@@ -229,6 +244,21 @@ def test_inplace_dtype(self, dtype1, dtype2):
229
244
with pytest .raises (ValueError ):
230
245
ia /= ib
231
246
247
+ @pytest .mark .parametrize ("dtype1" , get_all_dtypes (no_none = True ))
248
+ @pytest .mark .parametrize ("dtype2" , get_float_complex_dtypes ())
249
+ def test_inplace_dtype_explicit (self , dtype1 , dtype2 ):
250
+ a = numpy .array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
251
+ b = numpy .array ([5 , - 2 , - 10 , 1 , 10 ], dtype = dtype2 )
252
+ ia , ib = dpnp .array (a ), dpnp .array (b )
253
+
254
+ if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
255
+ result = dpnp .divide (ia , ib , out = ia )
256
+ expected = numpy .divide (a , b , out = a )
257
+ assert_dtype_allclose (result , expected )
258
+ else :
259
+ assert_raises (TypeError , numpy .divide , a , b , out = a )
260
+ assert_raises (ValueError , dpnp .divide , ia , ib , out = ia )
261
+
232
262
@pytest .mark .parametrize ("shape" , [(0 ,), (15 ,), (2 , 2 )])
233
263
def test_invalid_shape (self , shape ):
234
264
a , b = dpnp .arange (10 ), dpnp .arange (10 )
0 commit comments