Skip to content

Commit 56020d7

Browse files
committed
Final touches
1 parent 4a2adeb commit 56020d7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pandas/tests/frame/test_analytics.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def assert_stat_op_calc(opname, alternative, main_frame, has_skipna=True,
3333

3434
if check_dates:
3535
df = DataFrame({'b': date_range('1/1/2001', periods=2)})
36-
_f = getattr(df, opname)
37-
result = _f()
36+
result = getattr(df, opname)()
3837
assert isinstance(result, Series)
3938

4039
df['a'] = lrange(len(df))
@@ -86,7 +85,7 @@ def wrapper(x):
8685
r0 = getattr(all_na, opname)(axis=0)
8786
r1 = getattr(all_na, opname)(axis=1)
8887
if opname in ['sum', 'prod']:
89-
unit = int(opname == 'prod')
88+
unit = 1 if opname == 'prod' else 0 # result for empty sum/prod
9089
expected = pd.Series(unit, index=r0.index, dtype=r0.dtype)
9190
tm.assert_series_equal(r0, expected)
9291
expected = pd.Series(unit, index=r1.index, dtype=r1.dtype)
@@ -137,7 +136,7 @@ def wrapper(x):
137136
check_dtype=False)
138137

139138
# bad axis
140-
pytest.raises(ValueError, f, axis=2)
139+
tm.assert_raises_regex(ValueError, 'No axis named 2', f, axis=2)
141140

142141
# all NA case
143142
if has_skipna:
@@ -156,7 +155,7 @@ def assert_bool_op_api(opname, bool_frame_with_na, float_string_frame,
156155
has_bool_only=False):
157156
# make sure op works on mixed-type frame
158157
mixed = float_string_frame
159-
mixed['_bool_'] = np.random.randn(len(mixed)) > 0
158+
mixed['_bool_'] = np.random.randn(len(mixed)) > 0.5
160159
getattr(mixed, opname)(axis=0)
161160
getattr(mixed, opname)(axis=1)
162161

0 commit comments

Comments
 (0)