@@ -731,17 +731,23 @@ def test_series_ops_name_retention(flex, box, names, all_binary_operators):
731731 left = Series (range (10 ), name = names [0 ])
732732 right = Series (range (10 ), name = names [1 ])
733733
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+
734738 right = box (right )
735739 if flex :
736- name = op .__name__ .strip ("_" )
737- if name in ["and" , "rand" , "xor" , "rxor" , "or" , "ror" ]:
740+ if is_logical :
738741 # Series doesn't have these as flex methods
739742 return
740743 result = getattr (left , name )(right )
741744 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 )
743749
744- if box is pd .Index and op . __name__ . strip ( "_" ) in [ "rxor" , "ror" , "rand" ] :
750+ if box is pd .Index and is_rlogical :
745751 # Index treats these as set operators, so does not defer
746752 assert isinstance (result , pd .Index )
747753 return
0 commit comments