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
MAINT: stats._contains_nan: fix bug when -inf and inf are in sample #20467
Conversation
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.
Thanks @mdhaber
contains_nan = xp.isnan(xp.sum(a)) | ||
else: | ||
contains_nan = xp.any(xp.isnan(a)) | ||
if a.size == 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.
Oops, I should have used _array_api.size
here. Will do in gh-20667.
Title is prefixed with |
Might be tricky to backport because this is mixed with adding array API support to the function, which is a new feature. Up to you, though. |
Reference issue
Closes gh-20386
What does this implement/fix?
gh-20386 reported that
stats.kstest
returned NaNs when both positive and negative infinities were present in the sample. This fixes the (very old) underlying bug.Additional information
This includes all the gh-20292 commits, so that should merge first.
I could add a test for
_contains_nan
directly if desired. (Currently, this just adds a test for the reported issue inkstest
.)