-
Notifications
You must be signed in to change notification settings - Fork 172
test: div by zero returns nan #2636
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
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fa391dc
Add tests for div by zero
jrw34 2a6f16d
Use constructor eager for to cover backend testing
jrw34 6e6ee79
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] bbb6d8c
add lazy div by zero testing
jrw34 191f901
add lazy div by zero testing
jrw34 cc9c2fa
add collect call to lazy constructors
jrw34 57afe7e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] afde36b
Created individual tests for floordiv and truediv by zero
jrw34 81cebec
Merge branch 'main' into add-test-for-div-by-zero
jrw34 a87b195
Add polars backend specific division by zero return value
jrw34 8f7087c
Merge branch 'main' into add-test-for-div-by-zero
jrw34 901921f
Exclude floordiv tests for pandas versions < 2.0
jrw34 84d88be
Added pandas[nullable] conditional for floordiv by zero
jrw34 2a2883b
Add float div by zero test for truediv, make new test file
jrw34 260265d
Merge branch 'main' into add-test-for-div-by-zero
jrw34 830a9fc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1ac2297
Ruff fixes
jrw34 964122f
Merge branch 'main' into add-test-for-div-by-zero
FBruzzesi 33a00c5
Merge branch 'main' into add-test-for-div-by-zero
FBruzzesi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
@MarcoGorelli this might be worth reporting upstream as well. WDYT? Is this expected?
Repro:
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.
@FBruzzesi upstream is aware: pandas-dev/pandas#30188 on this one. This corner of NaN producing operations on
"numpy_nullable"backed values likely won't be resolved (pandas may be at yet another crossroads on this) so I think we should justxfailfor this specific test.Pinging @MarcoGorelli to verify.
Uh oh!
There was an error while loading. Please reload this page.
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.
@camriddell, @FBruzzesi, and @MarcoGorelli. Thank you for all of the review, I am happy to change this case to
xfailif needed so just let me know,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.
On second thought it let's keep the current code as it captures the behaviors of each of these backends, so if they change in the future we'll be aware of this shift.
Would it be possible to also add another variant of these tests that works with floating point values as the inputs for the numerator/denominator? We should see much more consistent results returned (e.g. see [inf, NaN, -inf]) across each of the backends.
Some thoughts on the oddities you observed. Feel free to ignore, I wanted to capture this in case we ever need to revisit this decision.
It seems that there are a few camps on the set of results that one would obtain from floor dividing two integer arrays (where the denom is 0):
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.
Interesting with the floating point differences, I will add that in. Given that there are now going to be 8 different test functions, should I create a
test_divsion_by_zero.pyfile to house the all these tests instead of bulking uparithmetic_tests.pyeven more?