Skip to content

Commit 6ab89f9

Browse files
committed
Review (WillAyd)
1 parent 3ae0127 commit 6ab89f9

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):
@@ -803,8 +803,9 @@ def alt(x):
803803
assert kurt.name is None
804804
assert kurt2.name == 'bar'
805805

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,
808809
has_numeric_only=False, check_dtype=True,
809810
check_dates=False, check_less_precise=False,
810811
skipna_alternative=None):
@@ -846,8 +847,8 @@ def wrapper(x):
846847
check_dtype=check_dtype,
847848
check_less_precise=check_less_precise)
848849
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,
851852
check_less_precise=check_less_precise)
852853

853854
# check dtypes
@@ -859,18 +860,18 @@ def wrapper(x):
859860
# bad axis
860861
tm.assert_raises_regex(ValueError, 'No axis named 2', f, axis=2)
861862
# 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)
864865

865866
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)
870871

871872
# all NA case
872873
if has_skipna:
873-
all_na = float_frame * np.NaN
874+
all_na = float_frame_ * np.NaN
874875
r0 = getattr(all_na, name)(axis=0)
875876
r1 = getattr(all_na, name)(axis=1)
876877
if name in ['sum', 'prod']:
@@ -1920,8 +1921,8 @@ def test_dot(self):
19201921
row = a.iloc[0].values
19211922

19221923
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)
19251926

19261927
with tm.assert_raises_regex(ValueError,
19271928
'Dot product shape mismatch'):
@@ -2085,6 +2086,9 @@ def test_n_error(self, df_main_dtypes, nselect_method, columns):
20852086
col = columns[1]
20862087
error_msg = self.dtype_error_msg_template.format(
20872088
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("]", "\\]"))
20882092
with tm.assert_raises_regex(TypeError, error_msg):
20892093
getattr(df, nselect_method)(2, columns)
20902094

0 commit comments

Comments
 (0)