File tree 2 files changed +15
-7
lines changed
2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -76,13 +76,8 @@ def cmp_method(self, other):
76
76
result = ops ._comp_method_OBJECT_ARRAY (op , self .values , other )
77
77
78
78
else :
79
-
80
- # numpy will show a DeprecationWarning on invalid elementwise
81
- # comparisons, this will raise in the future
82
- with warnings .catch_warnings (record = True ):
83
- warnings .filterwarnings ("ignore" , "elementwise" , FutureWarning )
84
- with np .errstate (all = 'ignore' ):
85
- result = op (self .values , np .asarray (other ))
79
+ with np .errstate (all = 'ignore' ):
80
+ result = op (self .values , np .asarray (other ))
86
81
87
82
# technically we could support bool dtyped Index
88
83
# for now just return the indexing array directly
Original file line number Diff line number Diff line change @@ -80,3 +80,16 @@ def test_numpy_ufuncs_other(indices, func):
80
80
else :
81
81
with pytest .raises (Exception ):
82
82
func (idx )
83
+
84
+
85
+ def test_elementwise_comparison_warning ():
86
+ # https://github.com/pandas-dev/pandas/issues/22698#issuecomment-458968300
87
+ # np.array([1, 2]) == 'a' returns False, and produces a
88
+ # FutureWarning that it'll be [False, False] in the future.
89
+ # We just want to ensure that comes through.
90
+ # When NumPy dev actually enforces this change, we'll need to skip
91
+ # this test.
92
+ idx = Index ([1 , 2 ])
93
+ with tm .assert_produces_warning (FutureWarning ,
94
+ check_stacklevel = False ):
95
+ idx == 'a'
You can’t perform that action at this time.
0 commit comments