Skip to content

Commit b043bb4

Browse files
committed
Consistent naming of parameters
1 parent 98f3243 commit b043bb4

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

pandas/tests/frame/test_analytics.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@
2525
import pandas.util._test_decorators as td
2626

2727

28-
def _check_stat_op(name, alternative, main_frame, float_frame,
28+
def _check_stat_op(opname, alternative, main_frame, float_frame,
2929
float_string_frame, has_skipna=True,
3030
has_numeric_only=False, check_dtype=True,
3131
check_dates=False, check_less_precise=False,
3232
skipna_alternative=None):
3333

34-
f = getattr(main_frame, name)
34+
f = getattr(main_frame, opname)
3535

3636
if check_dates:
3737
df = DataFrame({'b': date_range('1/1/2001', periods=2)})
38-
_f = getattr(df, name)
38+
_f = getattr(df, opname)
3939
result = _f()
4040
assert isinstance(result, Series)
4141

4242
df['a'] = lrange(len(df))
43-
result = getattr(df, name)()
43+
result = getattr(df, opname)()
4444
assert isinstance(result, Series)
4545
assert len(result)
4646

@@ -67,7 +67,7 @@ def wrapper(x):
6767
tm.assert_series_equal(result0, main_frame.apply(skipna_wrapper),
6868
check_dtype=check_dtype,
6969
check_less_precise=check_less_precise)
70-
if name in ['sum', 'prod']:
70+
if opname in ['sum', 'prod']:
7171
expected = main_frame.apply(skipna_wrapper, axis=1)
7272
tm.assert_series_equal(result1, expected, check_dtype=False,
7373
check_less_precise=check_less_precise)
@@ -84,30 +84,30 @@ def wrapper(x):
8484
# all NA case
8585
if has_skipna:
8686
all_na = float_frame * np.NaN
87-
r0 = getattr(all_na, name)(axis=0)
88-
r1 = getattr(all_na, name)(axis=1)
89-
if name in ['sum', 'prod']:
90-
unit = int(name == 'prod')
87+
r0 = getattr(all_na, opname)(axis=0)
88+
r1 = getattr(all_na, opname)(axis=1)
89+
if opname in ['sum', 'prod']:
90+
unit = int(opname == 'prod')
9191
expected = pd.Series(unit, index=r0.index, dtype=r0.dtype)
9292
tm.assert_series_equal(r0, expected)
9393
expected = pd.Series(unit, index=r1.index, dtype=r1.dtype)
9494
tm.assert_series_equal(r1, expected)
9595

9696
# make sure works on mixed-type frame
97-
getattr(float_string_frame, name)(axis=0)
98-
getattr(float_string_frame, name)(axis=1)
97+
getattr(float_string_frame, opname)(axis=0)
98+
getattr(float_string_frame, opname)(axis=1)
9999

100100
if has_numeric_only:
101-
getattr(float_string_frame, name)(axis=0, numeric_only=True)
102-
getattr(float_string_frame, name)(axis=1, numeric_only=True)
103-
getattr(float_frame, name)(axis=0, numeric_only=False)
104-
getattr(float_frame, name)(axis=1, numeric_only=False)
101+
getattr(float_string_frame, opname)(axis=0, numeric_only=True)
102+
getattr(float_string_frame, opname)(axis=1, numeric_only=True)
103+
getattr(float_frame, opname)(axis=0, numeric_only=False)
104+
getattr(float_frame, opname)(axis=1, numeric_only=False)
105105

106106

107-
def _check_bool_op(name, alternative, frame, float_string_frame,
107+
def _check_bool_op(opname, alternative, main_frame, float_string_frame,
108108
has_skipna=True, has_bool_only=False):
109109

110-
f = getattr(frame, name)
110+
f = getattr(main_frame, opname)
111111

112112
if has_skipna:
113113
def skipna_wrapper(x):
@@ -119,28 +119,28 @@ def wrapper(x):
119119

120120
result0 = f(axis=0, skipna=False)
121121
result1 = f(axis=1, skipna=False)
122-
tm.assert_series_equal(result0, frame.apply(wrapper))
123-
tm.assert_series_equal(result1, frame.apply(wrapper, axis=1),
122+
tm.assert_series_equal(result0, main_frame.apply(wrapper))
123+
tm.assert_series_equal(result1, main_frame.apply(wrapper, axis=1),
124124
check_dtype=False) # HACK: win32
125125
else:
126126
skipna_wrapper = alternative
127127
wrapper = alternative
128128

129129
result0 = f(axis=0)
130130
result1 = f(axis=1)
131-
tm.assert_series_equal(result0, frame.apply(skipna_wrapper))
132-
tm.assert_series_equal(result1, frame.apply(skipna_wrapper, axis=1),
131+
tm.assert_series_equal(result0, main_frame.apply(skipna_wrapper))
132+
tm.assert_series_equal(result1, main_frame.apply(skipna_wrapper, axis=1),
133133
check_dtype=False)
134134

135135
# bad axis
136136
pytest.raises(ValueError, f, axis=2)
137137

138138
# all NA case
139139
if has_skipna:
140-
all_na = frame * np.NaN
141-
r0 = getattr(all_na, name)(axis=0)
142-
r1 = getattr(all_na, name)(axis=1)
143-
if name == 'any':
140+
all_na = main_frame * np.NaN
141+
r0 = getattr(all_na, opname)(axis=0)
142+
r1 = getattr(all_na, opname)(axis=1)
143+
if opname == 'any':
144144
assert not r0.any()
145145
assert not r1.any()
146146
else:
@@ -150,8 +150,8 @@ def wrapper(x):
150150
# make sure works on mixed-type frame
151151
mixed = float_string_frame
152152
mixed['_bool_'] = np.random.randn(len(mixed)) > 0
153-
getattr(mixed, name)(axis=0)
154-
getattr(mixed, name)(axis=1)
153+
getattr(mixed, opname)(axis=0)
154+
getattr(mixed, opname)(axis=1)
155155

156156
class NonzeroFail(object):
157157

@@ -161,10 +161,10 @@ def __nonzero__(self):
161161
mixed['_nonzero_fail_'] = NonzeroFail()
162162

163163
if has_bool_only:
164-
getattr(mixed, name)(axis=0, bool_only=True)
165-
getattr(mixed, name)(axis=1, bool_only=True)
166-
getattr(frame, name)(axis=0, bool_only=False)
167-
getattr(frame, name)(axis=1, bool_only=False)
164+
getattr(mixed, opname)(axis=0, bool_only=True)
165+
getattr(mixed, opname)(axis=1, bool_only=True)
166+
getattr(main_frame, opname)(axis=0, bool_only=False)
167+
getattr(main_frame, opname)(axis=1, bool_only=False)
168168

169169

170170
class TestDataFrameAnalytics():

0 commit comments

Comments
 (0)