@@ -53,8 +53,8 @@ def test_corr_spearman(self, float_frame):
53
53
54
54
def _check_method (self , frame , method = 'pearson' ):
55
55
correls = frame .corr (method = method )
56
- exp = frame ['A' ].corr (frame ['C' ], method = method )
57
- tm .assert_almost_equal (correls ['A' ]['C' ], exp )
56
+ expected = frame ['A' ].corr (frame ['C' ], method = method )
57
+ tm .assert_almost_equal (correls ['A' ]['C' ], expected )
58
58
59
59
@td .skip_if_no_scipy
60
60
def test_corr_non_numeric (self , float_frame , float_string_frame ):
@@ -803,8 +803,9 @@ def alt(x):
803
803
assert kurt .name is None
804
804
assert kurt2 .name == 'bar'
805
805
806
- def _check_stat_op (self , name , alternative , main_frame , float_frame ,
807
- float_string_frame , has_skipna = True ,
806
+ # underscores added to distinguish argument names from fixture names
807
+ def _check_stat_op (self , name , alternative , main_frame , float_frame_ ,
808
+ float_string_frame_ , has_skipna = True ,
808
809
has_numeric_only = False , check_dtype = True ,
809
810
check_dates = False , check_less_precise = False ,
810
811
skipna_alternative = None ):
@@ -846,8 +847,8 @@ def wrapper(x):
846
847
check_dtype = check_dtype ,
847
848
check_less_precise = check_less_precise )
848
849
if name in ['sum' , 'prod' ]:
849
- exp = main_frame .apply (skipna_wrapper , axis = 1 )
850
- tm .assert_series_equal (result1 , exp , check_dtype = False ,
850
+ expected = main_frame .apply (skipna_wrapper , axis = 1 )
851
+ tm .assert_series_equal (result1 , expected , check_dtype = False ,
851
852
check_less_precise = check_less_precise )
852
853
853
854
# check dtypes
@@ -859,18 +860,18 @@ def wrapper(x):
859
860
# bad axis
860
861
tm .assert_raises_regex (ValueError , 'No axis named 2' , f , axis = 2 )
861
862
# make sure works on mixed-type frame
862
- getattr (float_string_frame , name )(axis = 0 )
863
- getattr (float_string_frame , name )(axis = 1 )
863
+ getattr (float_string_frame_ , name )(axis = 0 )
864
+ getattr (float_string_frame_ , name )(axis = 1 )
864
865
865
866
if has_numeric_only :
866
- getattr (float_string_frame , name )(axis = 0 , numeric_only = True )
867
- getattr (float_string_frame , name )(axis = 1 , numeric_only = True )
868
- getattr (float_frame , name )(axis = 0 , numeric_only = False )
869
- getattr (float_frame , name )(axis = 1 , numeric_only = False )
867
+ getattr (float_string_frame_ , name )(axis = 0 , numeric_only = True )
868
+ getattr (float_string_frame_ , name )(axis = 1 , numeric_only = True )
869
+ getattr (float_frame_ , name )(axis = 0 , numeric_only = False )
870
+ getattr (float_frame_ , name )(axis = 1 , numeric_only = False )
870
871
871
872
# all NA case
872
873
if has_skipna :
873
- all_na = float_frame * np .NaN
874
+ all_na = float_frame_ * np .NaN
874
875
r0 = getattr (all_na , name )(axis = 0 )
875
876
r1 = getattr (all_na , name )(axis = 1 )
876
877
if name in ['sum' , 'prod' ]:
@@ -1920,8 +1921,8 @@ def test_dot(self):
1920
1921
row = a .iloc [0 ].values
1921
1922
1922
1923
result = a .dot (row )
1923
- exp = a .dot (a .iloc [0 ])
1924
- tm .assert_series_equal (result , exp )
1924
+ expected = a .dot (a .iloc [0 ])
1925
+ tm .assert_series_equal (result , expected )
1925
1926
1926
1927
with tm .assert_raises_regex (ValueError ,
1927
1928
'Dot product shape mismatch' ):
@@ -2085,6 +2086,9 @@ def test_n_error(self, df_main_dtypes, nselect_method, columns):
2085
2086
col = columns [1 ]
2086
2087
error_msg = self .dtype_error_msg_template .format (
2087
2088
column = col , method = nselect_method , dtype = df [col ].dtype )
2089
+ # escape some characters that may be in the repr
2090
+ error_msg = (error_msg .replace ('(' , '\\ (' ).replace (")" , "\\ )" )
2091
+ .replace ("[" , "\\ [" ).replace ("]" , "\\ ]" ))
2088
2092
with tm .assert_raises_regex (TypeError , error_msg ):
2089
2093
getattr (df , nselect_method )(2 , columns )
2090
2094
0 commit comments