@@ -835,16 +835,9 @@ def test_frame_with_frame_reindex(self):
835
835
)
836
836
def test_binop_other (self , op , value , dtype ):
837
837
skip = {
838
- (operator .add , "bool" ),
839
- (operator .sub , "bool" ),
840
- (operator .mul , "bool" ),
841
838
(operator .truediv , "bool" ),
842
- (operator .mod , "i8" ),
843
- (operator .mod , "complex128" ),
844
839
(operator .pow , "bool" ),
845
840
}
846
- if (op , dtype ) in skip :
847
- pytest .skip (f"Invalid combination { op } ,{ dtype } " )
848
841
849
842
e = DummyElement (value , dtype )
850
843
s = DataFrame ({"A" : [e .value , e .value ]}, dtype = e .dtype )
@@ -857,26 +850,46 @@ def test_binop_other(self, op, value, dtype):
857
850
(operator .add , "<M8[ns]" ),
858
851
(operator .pow , "<m8[ns]" ),
859
852
(operator .mul , "<m8[ns]" ),
853
+ (operator .sub , "bool" ),
854
+ (operator .mod , "complex128" ),
860
855
}
861
856
862
857
if (op , dtype ) in invalid :
863
- msg = (
864
- None
865
- if (dtype == "<M8[ns]" and op == operator .add )
866
- or (dtype == "<m8[ns]" and op == operator .mul )
867
- else (
858
+ warn = None
859
+ if (dtype == "<M8[ns]" and op == operator .add ) or (
860
+ dtype == "<m8[ns]" and op == operator .mul
861
+ ):
862
+ msg = None
863
+ elif dtype == "complex128" :
864
+ msg = "ufunc 'remainder' not supported for the input types"
865
+ warn = UserWarning # "evaluating in Python space because ..."
866
+ elif op is operator .sub :
867
+ msg = "numpy boolean subtract, the `-` operator, is "
868
+ warn = UserWarning # "evaluating in Python space because ..."
869
+ else :
870
+ msg = (
868
871
f"cannot perform __{ op .__name__ } __ with this "
869
872
"index type: (DatetimeArray|TimedeltaArray)"
870
873
)
871
- )
872
874
873
875
with pytest .raises (TypeError , match = msg ):
874
- op (s , e .value )
876
+ with tm .assert_produces_warning (warn ):
877
+ op (s , e .value )
878
+
879
+ elif (op , dtype ) in skip :
880
+
881
+ msg = "operator '.*' not implemented for .* dtypes"
882
+ with pytest .raises (NotImplementedError , match = msg ):
883
+ with tm .assert_produces_warning (UserWarning ):
884
+ # "evaluating in Python space because ..."
885
+ op (s , e .value )
886
+
875
887
else :
876
888
# FIXME: Since dispatching to Series, this test no longer
877
889
# asserts anything meaningful
878
- result = op (s , e .value ).dtypes
879
- expected = op (s , value ).dtypes
890
+ with tm .assert_produces_warning (None ):
891
+ result = op (s , e .value ).dtypes
892
+ expected = op (s , value ).dtypes
880
893
tm .assert_series_equal (result , expected )
881
894
882
895
0 commit comments