Skip to content
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

REF: avoid catching all exceptions in libreduction #38285

Merged
merged 3 commits into from
Dec 17, 2020

Conversation

jbrockmendel
Copy link
Member

Most of the libreduction edits are from #35417

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Do we know now that the function in libreduction will never raise an error?

@jbrockmendel
Copy link
Member Author

Do we know now that the function in libreduction will never raise an error?

The relevant question isn't "will it ever raise" but "will it raise in the cython path but not in the python path". AFAICT IndexError is the only non-contrived way that happens

@jreback jreback added the Refactor Internal refactoring of code label Dec 4, 2020
@jreback jreback added this to the 1.2 milestone Dec 4, 2020
@jreback
Copy link
Contributor

jreback commented Dec 5, 2020

do you have objections @jorisvandenbossche

@jorisvandenbossche
Copy link
Member

"will it raise in the cython path but not in the python path". AFAICT IndexError is the only non-contrived way that happens

OK, I see, it's only removing the error catching specifically from calling the function on the chunk (which was re-raised as InvalidApply), not general errors from libreduction code

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

I think you can remove the InvalidApply class definition? (it seems no longer used)

# worth-retrying in pure-python?
raise
except IndexError:
# test_apply_mutate this is a rare case in which re-running
Copy link
Member

Choose a reason for hiding this comment

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

which test is this referring to? (I don't see a test_apply_mutate)

Copy link
Member Author

Choose a reason for hiding this comment

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

test_apply_mutate.py, will update to make clearer

Copy link
Contributor

Choose a reason for hiding this comment

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

@jbrockmendel is there something you were going to update here?

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for the reminder, just updated

# the function modified them.
mgr = self.dummy._mgr
self.orig_blklocs = mgr.blklocs
self.orig_blknos = mgr.blknos
Copy link
Member

Choose a reason for hiding this comment

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

Is this fixing a specific bug? (but don't see any test added)

Copy link
Member Author

Choose a reason for hiding this comment

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

without this we have other tests that fail in cython but not in python, but im not aware of any bugs this causes in master

Copy link
Member

Choose a reason for hiding this comment

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

You mean that on master the try: piece = f(chunk) ... would fail, and thus be elevated to the python level (where it worked), but with this fix ensures those specific cases don't fail anymore an work on the cython level?

Can you give an example of such a test?

Also, the issues number in the comment seems not directly related (well, it might be it was needed there as well, but since that's an open PR, that's a bit confusing reference)

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you give an example of such a test?

FAILED pandas/tests/groupby/test_apply_mutate.py::test_mutate_groups - ValueError: shape mismatch: value array of shape (1,6) could not be broa...

Will attempt to clarify .

@jorisvandenbossche jorisvandenbossche modified the milestones: 1.2, 1.3 Dec 8, 2020
@jreback
Copy link
Contributor

jreback commented Dec 8, 2020

this looks fine. @jorisvandenbossche any comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants