Skip to content

Commit ca259f9

Browse files
committed
Review (WillAyd)
1 parent 15eb579 commit ca259f9

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

pandas/tests/frame/test_analytics.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def test_corr_spearman(self, float_frame):
5353

5454
def _check_method(self, frame, method='pearson'):
5555
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)
5858

5959
@td.skip_if_no_scipy
6060
def test_corr_non_numeric(self, float_frame, float_string_frame):
@@ -799,8 +799,9 @@ def alt(x):
799799
assert kurt.name is None
800800
assert kurt2.name == 'bar'
801801

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,
804805
has_numeric_only=False, check_dtype=True,
805806
check_dates=False, check_less_precise=False,
806807
skipna_alternative=None):
@@ -842,8 +843,8 @@ def wrapper(x):
842843
check_dtype=check_dtype,
843844
check_less_precise=check_less_precise)
844845
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,
847848
check_less_precise=check_less_precise)
848849

849850
# check dtypes
@@ -855,18 +856,18 @@ def wrapper(x):
855856
# bad axis
856857
tm.assert_raises_regex(ValueError, 'No axis named 2', f, axis=2)
857858
# 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)
860861

861862
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)
866867

867868
# all NA case
868869
if has_skipna:
869-
all_na = float_frame * np.NaN
870+
all_na = float_frame_ * np.NaN
870871
r0 = getattr(all_na, name)(axis=0)
871872
r1 = getattr(all_na, name)(axis=1)
872873
if name in ['sum', 'prod']:
@@ -1914,8 +1915,8 @@ def test_dot(self):
19141915
row = a.iloc[0].values
19151916

19161917
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)
19191920

19201921
with tm.assert_raises_regex(ValueError,
19211922
'Dot product shape mismatch'):
@@ -2079,6 +2080,9 @@ def test_n_error(self, df_main_dtypes, nselect_method, columns):
20792080
col = columns[1]
20802081
error_msg = self.dtype_error_msg_template.format(
20812082
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("]", "\\]"))
20822086
with tm.assert_raises_regex(TypeError, error_msg):
20832087
getattr(df, nselect_method)(2, columns)
20842088

0 commit comments

Comments
 (0)