@@ -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 ):
@@ -799,8 +799,9 @@ def alt(x):
799
799
assert kurt .name is None
800
800
assert kurt2 .name == 'bar'
801
801
802
- def _check_stat_op (self , name , alternative , main_frame , float_frame ,
803
- float_string_frame , has_skipna = True ,
802
+ # underscores added to distinguish argument names from fixture names
803
+ def _check_stat_op (self , name , alternative , main_frame , float_frame_ ,
804
+ float_string_frame_ , has_skipna = True ,
804
805
has_numeric_only = False , check_dtype = True ,
805
806
check_dates = False , check_less_precise = False ,
806
807
skipna_alternative = None ):
@@ -842,8 +843,8 @@ def wrapper(x):
842
843
check_dtype = check_dtype ,
843
844
check_less_precise = check_less_precise )
844
845
if name in ['sum' , 'prod' ]:
845
- exp = main_frame .apply (skipna_wrapper , axis = 1 )
846
- tm .assert_series_equal (result1 , exp , check_dtype = False ,
846
+ expected = main_frame .apply (skipna_wrapper , axis = 1 )
847
+ tm .assert_series_equal (result1 , expected , check_dtype = False ,
847
848
check_less_precise = check_less_precise )
848
849
849
850
# check dtypes
@@ -855,18 +856,18 @@ def wrapper(x):
855
856
# bad axis
856
857
tm .assert_raises_regex (ValueError , 'No axis named 2' , f , axis = 2 )
857
858
# make sure works on mixed-type frame
858
- getattr (float_string_frame , name )(axis = 0 )
859
- getattr (float_string_frame , name )(axis = 1 )
859
+ getattr (float_string_frame_ , name )(axis = 0 )
860
+ getattr (float_string_frame_ , name )(axis = 1 )
860
861
861
862
if has_numeric_only :
862
- getattr (float_string_frame , name )(axis = 0 , numeric_only = True )
863
- getattr (float_string_frame , name )(axis = 1 , numeric_only = True )
864
- getattr (float_frame , name )(axis = 0 , numeric_only = False )
865
- getattr (float_frame , name )(axis = 1 , numeric_only = False )
863
+ getattr (float_string_frame_ , name )(axis = 0 , numeric_only = True )
864
+ getattr (float_string_frame_ , name )(axis = 1 , numeric_only = True )
865
+ getattr (float_frame_ , name )(axis = 0 , numeric_only = False )
866
+ getattr (float_frame_ , name )(axis = 1 , numeric_only = False )
866
867
867
868
# all NA case
868
869
if has_skipna :
869
- all_na = float_frame * np .NaN
870
+ all_na = float_frame_ * np .NaN
870
871
r0 = getattr (all_na , name )(axis = 0 )
871
872
r1 = getattr (all_na , name )(axis = 1 )
872
873
if name in ['sum' , 'prod' ]:
@@ -1914,8 +1915,8 @@ def test_dot(self):
1914
1915
row = a .iloc [0 ].values
1915
1916
1916
1917
result = a .dot (row )
1917
- exp = a .dot (a .iloc [0 ])
1918
- tm .assert_series_equal (result , exp )
1918
+ expected = a .dot (a .iloc [0 ])
1919
+ tm .assert_series_equal (result , expected )
1919
1920
1920
1921
with tm .assert_raises_regex (ValueError ,
1921
1922
'Dot product shape mismatch' ):
@@ -2079,6 +2080,9 @@ def test_n_error(self, df_main_dtypes, nselect_method, columns):
2079
2080
col = columns [1 ]
2080
2081
error_msg = self .dtype_error_msg_template .format (
2081
2082
column = col , method = nselect_method , dtype = df [col ].dtype )
2083
+ # escape some characters that may be in the repr
2084
+ error_msg = (error_msg .replace ('(' , '\\ (' ).replace (")" , "\\ )" )
2085
+ .replace ("[" , "\\ [" ).replace ("]" , "\\ ]" ))
2082
2086
with tm .assert_raises_regex (TypeError , error_msg ):
2083
2087
getattr (df , nselect_method )(2 , columns )
2084
2088
0 commit comments