-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Catch more specific exception in groupby.ops #28198
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
Conversation
# raise this error to the caller | ||
pass | ||
except TypeError as err: | ||
if "Cannot convert" in str(err): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the type(s) of exceptions that raise this not well defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cython raises this (with a message matching this pattern) if we pass a non-ndarray to something expected an ndarray. im not aware of any other cases we actually want to let pass here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you saw other non-Cython TypeErrors show up here then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we dont catch TypeError at all, the only tests that fail are ones where apply_frame_axis0 is raising because it expects an ndarray
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have asked this wrong but I don't think we are on the same page. So I was thinking to keep catching TypeError
but was questioning if we need the conditional block therein, as it diverges slightly from the pre-existing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we need the conditional block therein, as it diverges slightly from the pre-existing behavior.
Changing the behavior is intentional. ATM we are pass
ing on everything, and I want to pass
on a narrow set of TypeError
s.
except TypeError as err: | ||
if "Cannot convert" in str(err): | ||
# via apply_frame_axis0 if we pass a non-ndarray | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks fine, does this change any perf? IOW this looks like this is now taking a path that previously we raised (and then likely did an .apply on)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. Between this, #27909, and a not-yet-pushed branch that fixes incorrect exception handling in cython_agg_block, I'm pretty sure we'll end up falling back to python-space less often, but it isn't obvious what the individual changes affect perf-wise.
lgtm. can you rebase as I think we merged some other groupby/ops stuff. (just to be sure). |
Lots of these to whittle down.