14
14
from pandas import (
15
15
Categorical , DataFrame , Index , NaT , Series , bdate_range , date_range , isna )
16
16
from pandas .core import ops
17
- from pandas .core .indexes .base import InvalidIndexError
18
17
import pandas .core .nanops as nanops
19
18
import pandas .util .testing as tm
20
19
from pandas .util .testing import (
@@ -190,23 +189,7 @@ def test_scalar_na_logical_ops_corners(self):
190
189
operator .and_ ,
191
190
operator .or_ ,
192
191
operator .xor ,
193
- pytest .param (ops .rand_ ,
194
- marks = pytest .mark .xfail (reason = "GH#22092 Index "
195
- "implementation returns "
196
- "Index" ,
197
- raises = AssertionError ,
198
- strict = True )),
199
- pytest .param (ops .ror_ ,
200
- marks = pytest .mark .xfail (reason = "GH#22092 Index "
201
- "implementation raises" ,
202
- raises = InvalidIndexError ,
203
- strict = True )),
204
- pytest .param (ops .rxor ,
205
- marks = pytest .mark .xfail (reason = "GH#22092 Index "
206
- "implementation returns "
207
- "Index" ,
208
- raises = AssertionError ,
209
- strict = True ))
192
+
210
193
])
211
194
def test_logical_ops_with_index (self , op ):
212
195
# GH#22092, GH#19792
@@ -225,6 +208,19 @@ def test_logical_ops_with_index(self, op):
225
208
result = op (ser , idx2 )
226
209
assert_series_equal (result , expected )
227
210
211
+ @pytest .mark .parametrize ("op, expected" , [
212
+ (ops .rand_ , pd .Index ([False , True ])),
213
+ (ops .ror_ , pd .Index ([False , True ])),
214
+ (ops .rxor , pd .Index ([])),
215
+ ])
216
+ def test_reverse_ops_with_index (self , op , expected ):
217
+ # https://github.com/pandas-dev/pandas/pull/23628
218
+ # multi-set Index ops are buggy, so let's avoid duplicates...
219
+ ser = Series ([True , False ])
220
+ idx = Index ([False , True ])
221
+ result = op (ser , idx )
222
+ tm .assert_index_equal (result , expected )
223
+
228
224
def test_logical_ops_label_based (self ):
229
225
# GH#4947
230
226
# logical ops should be label based
0 commit comments