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