8000 TST: further clean up of frame/test_analytics by h-vetinari · Pull Request #23016 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST: further clean up of frame/test_analytics #23016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 7, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Correctly group tests within _check_[stat/bool]_op
  • Loading branch information
h-vetinari committed Oct 6, 2018
commit 4ba952e9bca41125729b2a3e5f0e45c338cf2833
43 changes: 22 additions & 21 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ def wrapper(x):

# bad axis
tm.assert_raises_regex(ValueError, 'No axis named 2', f, axis=2)
# make sure works on mixed-type frame
getattr(float_string_frame, name)(axis=0)
getattr(float_string_frame, name)(axis=1)

if has_numeric_only:
getattr(float_string_frame, name)(axis=0, numeric_only=True)
getattr(float_string_frame, name)(axis=1, numeric_only=True)
getattr(float_frame, name)(axis=0, numeric_only=False)
getattr(float_frame, name)(axis=1, numeric_only=False)

# all NA case
if has_skipna:
Expand All @@ -102,6 +93,16 @@ def wrapper(x):
expected = pd.Series(unit, index=r1.index, dtype=r1.dtype)
tm.assert_series_equal(r1, expected)

# make sure works on mixed-type frame
getattr(float_string_frame, name)(axis=0)
getattr(float_string_frame, name)(axis=1)

if has_numeric_only:
getattr(float_string_frame, name)(axis=0, numeric_only=True)
getattr(float_string_frame, name)(axis=1, numeric_only=True)
getattr(float_frame, name)(axis=0, numeric_only=False)
getattr(float_frame, name)(axis=1, numeric_only=False)


def _check_bool_op(name, alternative, frame, float_string_frame,
has_skipna=True, has_bool_only=False):
Expand Down Expand Up @@ -134,6 +135,18 @@ def wrapper(x):
# bad axis
pytest.raises(ValueError, f, axis=2)

# all NA case
if has_skipna:
all_na = frame * np.NaN
r0 = getattr(all_na, name)(axis=0)
r1 = getattr(all_na, name)(axis=1)
if name == 'any':
assert not r0.any()
assert not r1.any()
else:
assert r0.all()
assert r1.all()

# make sure works on mixed-type frame
mixed = float_string_frame
mixed['_bool_'] = np.random.randn(len(mixed)) > 0
Expand All @@ -153,18 +166,6 @@ def __nonzero__(self):
getattr(frame, name)(axis=0, bool_only=False)
getattr(frame, name)(axis=1, bool_only=False)

# all NA case
if has_skipna:
all_na = frame * np.NaN
r0 = getattr(all_na, name)(axis=0)
r1 = getattr(all_na, name)(axis=1)
if name == 'any':
assert not r0.any()
assert not r1.any()
else:
assert r0.all()
assert r1.all()


class TestDataFrameAnalytics():

Expand Down
0