Skip to content

Commit

Permalink
Update tests to not expect typerror/notimplementederror for transform…
Browse files Browse the repository at this point in the history
… funcs with fallback
  • Loading branch information
Kei committed May 8, 2024
1 parent 27565fa commit 25c0efb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pandas/tests/groupby/test_numeric_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,6 @@ def test_deprecate_numeric_only_series(dtype, groupby_func, request):
fails_on_numeric_object = (
"corr",
"cov",
"cummax",
"cummin",
"cumprod",
"cumsum",
"quantile",
)
# ops that give an object result on object input
Expand All @@ -358,6 +354,11 @@ def test_deprecate_numeric_only_series(dtype, groupby_func, request):
"max",
"prod",
"skew",
"cummax",
"cummin",
"cumsum",
# cumprod does not fail for object dtype, if element are numeric
"cumprod",
)

# Test default behavior; kernels that fail may be enabled in the future but kernels
Expand All @@ -376,6 +377,13 @@ def test_deprecate_numeric_only_series(dtype, groupby_func, request):
expected = expected.astype(object)
tm.assert_series_equal(result, expected)

valid_func_has_numeric_only = (
"cummin",
"cummax",
"cumsum",
# cumprod does not fail for object dtype, if element are numeric
"cumprod",
)
has_numeric_only = (
"first",
"last",
Expand All @@ -399,7 +407,7 @@ def test_deprecate_numeric_only_series(dtype, groupby_func, request):
msg = "got an unexpected keyword argument 'numeric_only'"
with pytest.raises(TypeError, match=msg):
method(*args, numeric_only=True)
elif dtype is object:
elif dtype is object and groupby_func not in valid_func_has_numeric_only:
msg = "|".join(
[
"SeriesGroupBy.sem called with numeric_only=True and dtype object",
Expand Down

0 comments on commit 25c0efb

Please sign in to comment.