MAINT: silence invalid warning for np.logaddexp(2) with NaN input - #32733
Merged
Merged
Conversation
ngoldbaum
reviewed
Sep 21, 2026
| else { | ||
| const @type@ tmp = x - y; | ||
| if (tmp > 0) { | ||
| if (isgreater(tmp, 0)) { |
Member
There was a problem hiding this comment.
This should be e.g. (@type@)0 instead of just 0. Also the other constants below. You could define e.g. const @type@ ZERO = 0.0; to make this a little nicer.
These functions accept floating point arguments and it's technically a violation of the C11 spec to pass an integer constant here. clang and gcc accept them anyway but let's not intentionally add code that violates the standard just because clang and gcc are OK with it.
Contributor
Author
There was a problem hiding this comment.
Thanks, I'll fix that.
Member
|
Thanks @mdhaber! |
Riaz1729
pushed a commit
to Riaz1729/numpy
that referenced
this pull request
Sep 23, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR summary
On (at least?) some platforms, including my Windows machine,
np.logaddexp/np.logaddexp2with NaN input produceinvalidwarnings.Based on the behavior of other ufuncs and other precedent (e.g. gh-12236, gh-15988, gh-32602, and now gh-32706), I don't think this is desired anymore. This PR eliminates the inadvertent warning by using floating point exception-quiet comparison implementations from the C standard library.
Additional information
I encountered this while developing SciPy. I thought it would be better to fix the source rather than leaving the
np.errstatein the code indefinitely.AI Disclosure
OpenAI Codex was used to inspect the relevant implementation and tests, draft
the code changes and regression tests, and prepare this AI disclosure.