Skip to content

Commit fce97bd

Browse files
committed
Modified tests
1 parent e0f3b1d commit fce97bd

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

pandas/core/generic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11578,7 +11578,8 @@ def _accum_func(
1157811578
*args,
1157911579
**kwargs,
1158011580
):
11581-
skipna = nv.validate_cum_func_with_skipna(skipna, args, kwargs, name)
11581+
if name not in ["cumprod", "cumsum"]:
11582+
skipna = nv.validate_cum_func_with_skipna(skipna, args, kwargs, name)
1158211583
if axis is None:
1158311584
axis = 0
1158411585
else:

pandas/tests/groupby/test_api.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def test_frame_consistency(groupby_func):
184184
exclude_expected = {"skipna", "args"}
185185
exclude_result = {"numeric_only"}
186186
elif groupby_func in ("cumprod", "cumsum"):
187-
exclude_expected = {"skipna"}
187+
exclude_expected = {"args", "kwargs"}
188+
exclude_result = {"numeric_only"}
188189
elif groupby_func in ("pct_change",):
189190
exclude_expected = {"kwargs"}
190191
exclude_result = {"axis"}
@@ -242,7 +243,8 @@ def test_series_consistency(request, groupby_func):
242243
exclude_expected = {"skipna", "args"}
243244
exclude_result = {"numeric_only"}
244245
elif groupby_func in ("cumprod", "cumsum"):
245-
exclude_expected = {"skipna"}
246+
exclude_expected = {"args", "kwargs"}
247+
exclude_result = {"numeric_only"}
246248
elif groupby_func in ("pct_change",):
247249
exclude_expected = {"kwargs"}
248250
exclude_result = {"axis"}

pandas/tests/groupby/test_function.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def test_axis1_numeric_only(request, groupby_func, numeric_only):
547547
kwargs["numeric_only"] = numeric_only
548548

549549
# Functions without numeric_only and axis args
550-
no_args = ("cumprod", "cumsum", "diff", "fillna", "pct_change", "rank", "shift")
550+
no_args = ("diff", "fillna", "pct_change", "rank", "shift")
551551
# Functions with axis args
552552
has_axis = (
553553
"cumprod",
@@ -565,13 +565,8 @@ def test_axis1_numeric_only(request, groupby_func, numeric_only):
565565
warn_msg = f"DataFrameGroupBy.{groupby_func} with axis=1 is deprecated"
566566
if numeric_only is not None and groupby_func in no_args:
567567
msg = "got an unexpected keyword argument 'numeric_only'"
568-
if groupby_func in ["cumprod", "cumsum"]:
569-
with pytest.raises(TypeError, match=msg):
570-
with tm.assert_produces_warning(FutureWarning, match=warn_msg):
571-
method(*args, **kwargs)
572-
else:
573-
with pytest.raises(TypeError, match=msg):
574-
method(*args, **kwargs)
568+
with pytest.raises(TypeError, match=msg):
569+
method(*args, **kwargs)
575570
elif groupby_func not in has_axis:
576571
msg = "got an unexpected keyword argument 'axis'"
577572
with pytest.raises(TypeError, match=msg):
@@ -814,11 +809,13 @@ def test_numpy_compat(func):
814809
g = df.groupby("A")
815810

816811
msg = "numpy operations are not valid with groupby"
812+
warn_msg = f"DataFrameGroupBy.{func} with axis=1 is deprecated"
817813

818-
with pytest.raises(UnsupportedFunctionCall, match=msg):
819-
getattr(g, func)(1, 2, 3)
820-
with pytest.raises(UnsupportedFunctionCall, match=msg):
821-
getattr(g, func)(foo=1)
814+
with pytest.raises(FutureWarning, match=warn_msg):
815+
with pytest.raises(UnsupportedFunctionCall, match=msg):
816+
getattr(g, func)(1, 2, 3)
817+
with pytest.raises(UnsupportedFunctionCall, match=msg):
818+
getattr(g, func)(foo=1)
822819

823820

824821
def test_cummin(dtypes_for_minmax):

0 commit comments

Comments
 (0)