-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
gh-104263: Rely on Py_NAN and introduce Py_INFINITY #104202
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c88a6fb
MAINT: Rely on Py_NAN and Py_HUGE_VAL being correctly defined
seberg 230882c
MAINT: Introduce and use `Py_INFINIY`; rely on NaN being defined
seberg fd39437
TST: Add some tests around (c)math.nan and nan parsing signs
seberg 1e42249
Change Py_HUGE_VAL to Py_INFINITY where I had missed/forgotten it
seberg efd67bc
Add news entry
mdickinson e15236d
One more Py_HUGE_VAL -> Py_INFINITY replacement
mdickinson 18a05cb
And another Py_HUGE_VAL -> Py_INFINITY replacement
mdickinson fabf7d3
Add acknowledgement in news entry
mdickinson e8c36a2
Fix spelling of Sebastian's name.
mdickinson a35ae19
Rely on C99 NAN being defined and ensure NaN sign for creation functions
seberg 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
6 changes: 6 additions & 0 deletions
6
Misc/NEWS.d/next/Core and Builtins/2023-05-08-10-34-55.gh-issue-104263.ctHWI8.rst
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Fix ``float("nan")`` to produce a quiet NaN on platforms (like MIPS) where | ||
the meaning of the signalling / quiet bit is inverted from its usual | ||
meaning. Also introduce a new macro ``Py_INFINITY`` matching C99's | ||
``INFINITY``, and refactor internals to rely on C99's ``NAN`` and | ||
``INFINITY`` macros instead of hard-coding bit patterns for infinities and | ||
NaNs. Thanks Sebastian Berg. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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.
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.
OK, did the minimal thing and added
fabs
specifically where it seems possibly interesting (there is the Unpack2 for float16 unpacking that doesn't test yet, but used-Py_NAN
explicitly).I was assuming the
__builtin_nan
is just predating NAN in C99 requirement, but can undo.For what its worth, NumPy creates NaNs all over with the same system dependent sign bit I suspect, and nobody ever complained.
EDIT/NOTE: Buildbot tests should be rerun probably.
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.
Yep, agreed that getting rid of that use of
__builtin_nan
looks like the right thing to do - I would have done that in a followup PR if you hadn't done it here.