@@ -731,17 +731,23 @@ def test_series_ops_name_retention(flex, box, names, all_binary_operators):
731
731
left = Series (range (10 ), name = names [0 ])
732
732
right = Series (range (10 ), name = names [1 ])
733
733
734
+ name = op .__name__ .strip ("_" )
735
+ is_logical = name in ["and" , "rand" , "xor" , "rxor" , "or" , "ror" ]
736
+ is_rlogical = is_logical and name .startswith ("r" )
737
+
734
738
right = box (right )
735
739
if flex :
736
- name = op .__name__ .strip ("_" )
737
- if name in ["and" , "rand" , "xor" , "rxor" , "or" , "ror" ]:
740
+ if is_logical :
738
741
# Series doesn't have these as flex methods
739
742
return
740
743
result = getattr (left , name )(right )
741
744
else :
742
- result = op (left , right )
745
+ # GH#37374 logical ops behaving as set ops deprecated
746
+ warn = FutureWarning if is_rlogical and box is Index else None
747
+ with tm .assert_produces_warning (warn , check_stacklevel = False ):
748
+ result = op (left , right )
743
749
744
- if box is pd .Index and op . __name__ . strip ( "_" ) in [ "rxor" , "ror" , "rand" ] :
750
+ if box is pd .Index and is_rlogical :
745
751
# Index treats these as set operators, so does not defer
746
752
assert isinstance (result , pd .Index )
747
753
return
0 commit comments