@@ -94,7 +94,7 @@ def test_validate_index():
94
94
95
95
def test_operators ():
96
96
# For every operator, we test that it works for the required type
97
- # combinations and raises TypeError otherwise
97
+ # combinations and assert_raises TypeError otherwise
98
98
binary_op_dtypes = {
99
99
"__add__" : "numeric" ,
100
100
"__and__" : "integer_or_boolean" ,
@@ -178,25 +178,25 @@ def _array_vals():
178
178
# See the promotion table in NEP 47 or the array
179
179
# API spec page on type promotion. Mixed kind
180
180
# promotion is not defined.
181
- if (x .dtype == uint64 and y .dtype in [int8 , int16 , int32 , int64 ]
182
- or y .dtype == uint64 and x .dtype in [int8 , int16 , int32 , int64 ]
183
- or x .dtype in _integer_dtypes and y .dtype not in _integer_dtypes
184
- or y .dtype in _integer_dtypes and x .dtype not in _integer_dtypes
185
- or x .dtype in _boolean_dtypes and y .dtype not in _boolean_dtypes
186
- or y .dtype in _boolean_dtypes and x .dtype not in _boolean_dtypes
187
- or x .dtype in _floating_dtypes and y .dtype not in _floating_dtypes
188
- or y .dtype in _floating_dtypes and x .dtype not in _floating_dtypes
189
- ):
190
- assert_raises (TypeError , lambda : getattr (x , _op )(y ))
181
+ if (op not in comparison_ops and
182
+ (x .dtype == uint64 and y .dtype in [int8 , int16 , int32 , int64 ]
183
+ or y .dtype == uint64 and x .dtype in [int8 , int16 , int32 , int64 ]
184
+ or x .dtype in _integer_dtypes and y .dtype not in _integer_dtypes
185
+ or y .dtype in _integer_dtypes and x .dtype not in _integer_dtypes
186
+ or x .dtype in _boolean_dtypes and y .dtype not in _boolean_dtypes
187
+ or y .dtype in _boolean_dtypes and x .dtype not in _boolean_dtypes
188
+ or x .dtype in _floating_dtypes and y .dtype not in _floating_dtypes
189
+ or y .dtype in _floating_dtypes and x .dtype not in _floating_dtypes
190
+ )):
191
+ assert_raises (TypeError , lambda : getattr (x , _op )(y ), _op )
191
192
# Ensure in-place operators only promote to the same dtype as the left operand.
192
193
elif (
193
194
_op .startswith ("__i" )
194
195
and result_type (x .dtype , y .dtype ) != x .dtype
195
196
):
196
197
assert_raises (TypeError , lambda : getattr (x , _op )(y ), _op )
197
198
# Ensure only those dtypes that are required for every operator are allowed.
198
- elif (dtypes == "all" and (x .dtype in _boolean_dtypes and y .dtype in _boolean_dtypes
199
- or x .dtype in _numeric_dtypes and y .dtype in _numeric_dtypes )
199
+ elif (dtypes == "all"
200
200
or (dtypes == "real numeric" and x .dtype in _real_numeric_dtypes and y .dtype in _real_numeric_dtypes )
201
201
or (dtypes == "numeric" and x .dtype in _numeric_dtypes and y .dtype in _numeric_dtypes )
202
202
or dtypes == "integer" and x .dtype in _integer_dtypes and y .dtype in _integer_dtypes
@@ -207,7 +207,7 @@ def _array_vals():
207
207
):
208
208
getattr (x , _op )(y )
209
209
else :
210
- assert_raises (TypeError , lambda : getattr (x , _op )(y ), _op )
210
+ assert_raises (TypeError , lambda : getattr (x , _op )(y ), ( x , _op , y ) )
211
211
212
212
unary_op_dtypes = {
213
213
"__abs__" : "numeric" ,
0 commit comments