Skip to content

CLN: Don't intercept NotImplementedError in _cython_transform #49742

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

Conversation

rhshadrach
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Ref: #49665 (comment)

The one place in groupby where there is raise NotImplementedError is in _reconstruct_ea_result. This is not hit by tests.

cc @jbrockmendel

@@ -1362,8 +1362,9 @@ def arr_func(bvalues: ArrayLike) -> ArrayLike:
arr_func, ignore_failures=numeric_only is lib.no_default
)
except NotImplementedError as err:
# For NotImplementedError, args[0] is the error message
raise TypeError(err.args[0]) from err
# For NotImplementedError, args[0] is the error message when available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im fine with this, but FWIW id just not catch this and let the NotImplementedError bubble up

Copy link
Member Author

@rhshadrach rhshadrach Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - I'll take that approach here. The only functions in our test that currently raise here are cumsum, cummin, cummax, and cumprod. I'm thinking longer term it'd be better to provide a Python fallback for object dtypes where cumsum (on strings, at least), cummin, and cummax could be successful, and cumprod will then raise the proper TypeError. Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable

@rhshadrach rhshadrach changed the title CLN: Handle no message for NotImplementedError in _cython_transform CLN: Don't intercept NotImplementedError in _cython_transform Nov 17, 2022
Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@WillAyd
Copy link
Member

WillAyd commented Nov 18, 2022

lgtm. is this not user facing at all / worth a whatsnew?

@rhshadrach
Copy link
Member Author

lgtm. is this not user facing at all / worth a whatsnew?

This was changed from raising NotImplementedError to a TypeError in #49665. So this PR is really just reverting that change.

@WillAyd WillAyd merged commit 6b575b4 into pandas-dev:main Nov 18, 2022
@rhshadrach rhshadrach deleted the groupby_notimplementederror_exception branch November 26, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants