@@ -875,7 +875,8 @@ def test_medium_complex_frame_alignment(self, engine, parser, r1, c1, r2, c2):
875875 def test_basic_frame_series_alignment (
876876 self , engine , parser , index_name , r_idx_type , c_idx_type
877877 ):
878- def testit (r_idx_type , c_idx_type , index_name ):
878+ with warnings .catch_warnings (record = True ):
879+ warnings .simplefilter ("always" , RuntimeWarning )
879880 df = tm .makeCustomDataframe (
880881 10 , 10 , data_gen_f = f , r_idx_type = r_idx_type , c_idx_type = c_idx_type
881882 )
@@ -894,48 +895,31 @@ def testit(r_idx_type, c_idx_type, index_name):
894895 expected = df + s
895896 tm .assert_frame_equal (res , expected )
896897
897- with warnings .catch_warnings (record = True ):
898- warnings .simplefilter ("always" , RuntimeWarning )
899-
900- testit (r_idx_type , c_idx_type , index_name )
901-
902898 @pytest .mark .parametrize ("index_name" , ["index" , "columns" ])
903- def test_basic_series_frame_alignment (self , engine , parser , index_name ):
904- def testit (r_idx_type , c_idx_type , index_name ):
905- df = tm .makeCustomDataframe (
906- 10 , 7 , data_gen_f = f , r_idx_type = r_idx_type , c_idx_type = c_idx_type
907- )
908- index = getattr (df , index_name )
909- s = Series (np .random .randn (5 ), index [:5 ])
910- if should_warn (s .index , df .index ):
911- with tm .assert_produces_warning (RuntimeWarning ):
912- res = pd .eval ("s + df" , engine = engine , parser = parser )
913- else :
899+ @pytest .mark .parametrize (
900+ "r_idx_type, c_idx_type" ,
901+ list (product (["i" , "u" , "s" ], ["i" , "u" , "s" ])) + [("dt" , "dt" )],
902+ )
903+ @pytest .mark .filterwarnings ("ignore::RuntimeWarning" )
904+ def test_basic_series_frame_alignment (
905+ self , engine , parser , index_name , r_idx_type , c_idx_type
906+ ):
907+ df = tm .makeCustomDataframe (
908+ 10 , 7 , data_gen_f = f , r_idx_type = r_idx_type , c_idx_type = c_idx_type
909+ )
910+ index = getattr (df , index_name )
911+ s = Series (np .random .randn (5 ), index [:5 ])
912+ if should_warn (s .index , df .index ):
913+ with tm .assert_produces_warning (RuntimeWarning ):
914914 res = pd .eval ("s + df" , engine = engine , parser = parser )
915+ else :
916+ res = pd .eval ("s + df" , engine = engine , parser = parser )
915917
916- if r_idx_type == "dt" or c_idx_type == "dt" :
917- expected = df .add (s ) if engine == "numexpr" else s + df
918- else :
919- expected = s + df
920- tm .assert_frame_equal (res , expected )
921-
922- # only test dt with dt, otherwise weird joins result
923- args = product (["i" , "u" , "s" ], ["i" , "u" , "s" ])
924- with warnings .catch_warnings (record = True ):
925- # avoid warning about comparing strings and ints
926- warnings .simplefilter ("ignore" , RuntimeWarning )
927-
928- for r_idx_type , c_idx_type in args :
929- testit (r_idx_type , c_idx_type , index_name )
930-
931- # dt with dt
932- args = product (["dt" ], ["dt" ])
933- with warnings .catch_warnings (record = True ):
934- # avoid warning about comparing strings and ints
935- warnings .simplefilter ("ignore" , RuntimeWarning )
936-
937- for r_idx_type , c_idx_type in args :
938- testit (r_idx_type , c_idx_type , index_name )
918+ if r_idx_type == "dt" or c_idx_type == "dt" :
919+ expected = df .add (s ) if engine == "numexpr" else s + df
920+ else :
921+ expected = s + df
922+ tm .assert_frame_equal (res , expected )
939923
940924 @pytest .mark .parametrize ("c_idx_type" , index_types )
941925 @pytest .mark .parametrize ("r_idx_type" , lhs_index_types )
0 commit comments