Skip to content

Commit 98f3243

Browse files
committed
Correctly group tests within _check_[stat/bool]_op
1 parent 6c4a702 commit 98f3243

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

pandas/tests/frame/test_analytics.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ def wrapper(x):
8080

8181
# bad axis
8282
tm.assert_raises_regex(ValueError, 'No axis named 2', f, axis=2)
83-
# make sure works on mixed-type frame
84-
getattr(float_string_frame, name)(axis=0)
85-
getattr(float_string_frame, name)(axis=1)
86-
87-
if has_numeric_only:
88-
getattr(float_string_frame, name)(axis=0, numeric_only=True)
89-
getattr(float_string_frame, name)(axis=1, numeric_only=True)
90-
getattr(float_frame, name)(axis=0, numeric_only=False)
91-
getattr(float_frame, name)(axis=1, numeric_only=False)
9283

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

96+
# make sure works on mixed-type frame
97+
getattr(float_string_frame, name)(axis=0)
98+
getattr(float_string_frame, name)(axis=1)
99+
100+
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)
105+
105106

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

138+
# all NA case
139+
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':
144+
assert not r0.any()
145+
assert not r1.any()
146+
else:
147+
assert r0.all()
148+
assert r1.all()
149+
137150
# make sure works on mixed-type frame
138151
mixed = float_string_frame
139152
mixed['_bool_'] = np.random.randn(len(mixed)) > 0
@@ -153,18 +166,6 @@ def __nonzero__(self):
153166
getattr(frame, name)(axis=0, bool_only=False)
154167
getattr(frame, name)(axis=1, bool_only=False)
155168

156-
# all NA case
157-
if has_skipna:
158-
all_na = frame * np.NaN
159-
r0 = getattr(all_na, name)(axis=0)
160-
r1 = getattr(all_na, name)(axis=1)
161-
if name == 'any':
162-
assert not r0.any()
163-
assert not r1.any()
164-
else:
165-
assert r0.all()
166-
assert r1.all()
167-
168169

169170
class TestDataFrameAnalytics():
170171

0 commit comments

Comments
 (0)