@@ -93,23 +93,27 @@ def test_x_and_out_broadcast(self, ufunc):
93
93
(np .add , operator .__add__ , operator .__iadd__ ),
94
94
(np .subtract , operator .__sub__ , operator .__isub__ ),
95
95
(np .multiply , operator .__mul__ , operator .__imul__ ),
96
- # divide
97
- # true_divide?
96
+ (np .divide , operator .__truediv__ , operator .__itruediv__ ),
97
+ (np .floor_divide , operator .__floordiv__ , operator .__ifloordiv__ ),
98
+ (np .float_power , operator .__pow__ , operator .__ipow__ ),
99
+
100
+
98
101
# remainder vs fmod?
99
102
# pow vs power vs float_power
100
103
]
101
104
102
105
ufuncs_with_dunders = [ufunc for ufunc , _ , _ in ufunc_op_iop_numeric ]
106
+ numeric_binary_ufuncs = [np .float_power , np .power ,]
103
107
104
- numeric_binary_ufuncs = [np .float_power , np .power ,
105
108
# these are not implemented for complex inputs
106
- # np.hypot, np.arctan2, np.copysign,
107
- # np.floor_divide , np.fmax , np.fmin , np.fmod ,
108
- # np.heaviside, np.logaddexp, np.logaddexp2, np.maximum, np.minimum,
109
+ no_complex = [ np . floor_divide , np .hypot , np .arctan2 , np .copysign , np . fmax ,
110
+ np .fmin , np .fmod , np .heaviside , np .logaddexp , np . logaddexp2 ,
111
+ np .maximum , np .minimum ,
109
112
]
110
113
111
114
parametrize_binary_ufuncs = pytest .mark .parametrize (
112
- 'ufunc' , ufuncs_with_dunders + numeric_binary_ufuncs )
115
+ 'ufunc' , ufuncs_with_dunders + numeric_binary_ufuncs + no_complex )
116
+
113
117
114
118
115
119
# TODO: these snowflakes need special handling
@@ -159,6 +163,9 @@ def test_xy_and_out_casting(self, ufunc, casting, out_dtype):
159
163
x , y = self .get_xy (ufunc )
160
164
out = np .empty_like (x , dtype = out_dtype )
161
165
166
+ if ufunc in no_complex and np .issubdtype (out_dtype , np .complexfloating ):
167
+ pytest .skip (f'{ ufunc } does not accept complex.' )
168
+
162
169
can_cast_x = np .can_cast (x , out_dtype , casting = casting )
163
170
can_cast_y = np .can_cast (y , out_dtype , casting = casting )
164
171
@@ -208,12 +215,13 @@ def test_basic(self, ufunc, op, iop):
208
215
assert_equal (op (a .tolist (), a ), ufunc (a , a .tolist ()))
209
216
210
217
# __iadd__
211
- a0 = np .array ([1 , 2 , 3 ])
218
+ a0 = np .array ([2 , 4 , 6 ])
212
219
a = a0 .copy ()
220
+
213
221
iop (a , 2 ) # modifies a in-place
214
222
assert_equal (a , op (a0 , 2 ))
215
223
216
- a0 = np .array ([1 , 2 , 3 ])
224
+ a0 = np .array ([2 , 4 , 6 ])
217
225
a = a0 .copy ()
218
226
iop (a , a )
219
227
assert_equal (a , op (a0 , a0 ))
@@ -225,6 +233,9 @@ def test_other_scalar(self, ufunc, op, iop, other_dtype):
225
233
a = np .array ([1 , 2 , 3 ])
226
234
b = other_dtype (3 )
227
235
236
+ if ufunc in no_complex and issubclass (other_dtype , np .complexfloating ):
237
+ pytest .skip (f'{ ufunc } does not accept complex.' )
238
+
228
239
# __op__
229
240
result = op (a , b )
230
241
assert_equal (result , ufunc (a , b ))
@@ -253,9 +264,13 @@ def test_other_scalar(self, ufunc, op, iop, other_dtype):
253
264
@pytest .mark .parametrize ("other_dtype" , dtypes_numeric )
254
265
def test_other_array (self , ufunc , op , iop , other_dtype ):
255
266
"""Test op/iop/rop when the other argument is an array of a different dtype."""
256
- # __op__
257
267
a = np .array ([1 , 2 , 3 ])
258
268
b = np .array ([5 , 6 , 7 ], dtype = other_dtype )
269
+
270
+ if ufunc in no_complex and issubclass (other_dtype , np .complexfloating ):
271
+ pytest .skip (f'{ ufunc } does not accept complex.' )
272
+
273
+ # __op__
259
274
result = op (a , b )
260
275
assert_equal (result , ufunc (a , b ))
261
276
assert result .dtype == np .result_type (a , b )
0 commit comments