Skip to content

Commit 002d98a

Browse files
committed
Adjust more tests
1 parent e6e2c89 commit 002d98a

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

pandas/tests/arithmetic/test_numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ def test_fill_value_inf_masking():
14511451
expected = pd.DataFrame(
14521452
{"A": [np.inf, 1.0, 0.0, 1.0], "B": [0.0, np.nan, 0.0, np.nan]}
14531453
)
1454-
tm.assert_frame_equal(result, expected)
1454+
tm.assert_frame_equal(result, expected, check_index_type=False)
14551455

14561456

14571457
def test_dataframe_div_silenced():

pandas/tests/groupby/test_groupby.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def max_value(group):
7474
tm.assert_series_equal(result, expected)
7575

7676

77-
def test_pass_args_kwargs(ts, tsframe):
77+
def test_pass_args_kwargs(ts):
7878
def f(x, q=None, axis=0):
7979
return np.percentile(x, q, axis=axis)
8080

@@ -100,31 +100,34 @@ def f(x, q=None, axis=0):
100100
tm.assert_series_equal(apply_result, agg_expected)
101101
tm.assert_series_equal(trans_result, trans_expected)
102102

103-
# DataFrame
104-
for as_index in [True, False]:
105-
df_grouped = tsframe.groupby(lambda x: x.month, as_index=as_index)
106-
warn = None if as_index else FutureWarning
107-
msg = "A grouping .* was excluded from the result"
108-
with tm.assert_produces_warning(warn, match=msg):
109-
agg_result = df_grouped.agg(np.percentile, 80, axis=0)
110-
with tm.assert_produces_warning(warn, match=msg):
111-
apply_result = df_grouped.apply(DataFrame.quantile, 0.8)
112-
with tm.assert_produces_warning(warn, match=msg):
113-
expected = df_grouped.quantile(0.8)
114-
tm.assert_frame_equal(apply_result, expected, check_names=False)
115-
tm.assert_frame_equal(agg_result, expected)
116-
117-
apply_result = df_grouped.apply(DataFrame.quantile, [0.4, 0.8])
118-
with tm.assert_produces_warning(warn, match=msg):
119-
expected_seq = df_grouped.quantile([0.4, 0.8])
120-
tm.assert_frame_equal(apply_result, expected_seq, check_names=False)
121-
122-
with tm.assert_produces_warning(warn, match=msg):
123-
agg_result = df_grouped.agg(f, q=80)
124-
with tm.assert_produces_warning(warn, match=msg):
125-
apply_result = df_grouped.apply(DataFrame.quantile, q=0.8)
126-
tm.assert_frame_equal(agg_result, expected)
127-
tm.assert_frame_equal(apply_result, expected, check_names=False)
103+
104+
def test_pass_args_kwargs_dataframe(tsframe, as_index):
105+
def f(x, q=None, axis=0):
106+
return np.percentile(x, q, axis=axis)
107+
108+
df_grouped = tsframe.groupby(lambda x: x.month, as_index=as_index)
109+
warn = None if as_index else FutureWarning
110+
msg = "A grouping .* was excluded from the result"
111+
with tm.assert_produces_warning(warn, match=msg):
112+
agg_result = df_grouped.agg(np.percentile, 80, axis=0)
113+
with tm.assert_produces_warning(warn, match=msg):
114+
apply_result = df_grouped.apply(DataFrame.quantile, 0.8)
115+
with tm.assert_produces_warning(warn, match=msg):
116+
expected = df_grouped.quantile(0.8)
117+
tm.assert_frame_equal(apply_result, expected, check_names=False)
118+
tm.assert_frame_equal(agg_result, expected)
119+
120+
apply_result = df_grouped.apply(DataFrame.quantile, [0.4, 0.8])
121+
with tm.assert_produces_warning(warn, match=msg):
122+
expected_seq = df_grouped.quantile([0.4, 0.8])
123+
tm.assert_frame_equal(apply_result, expected_seq, check_names=False)
124+
125+
with tm.assert_produces_warning(warn, match=msg):
126+
agg_result = df_grouped.agg(f, q=80)
127+
with tm.assert_produces_warning(warn, match=msg):
128+
apply_result = df_grouped.apply(DataFrame.quantile, q=0.8)
129+
tm.assert_frame_equal(agg_result, expected)
130+
tm.assert_frame_equal(apply_result, expected, check_names=False)
128131

129132

130133
def test_len():

0 commit comments

Comments
 (0)