-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-47031: Improve documentation for math.nan
#32170
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
bpo-47031: Improve documentation for math.nan
#32170
Conversation
Doc/library/math.rst
Outdated
False | ||
>>> math.nan is math.nan | ||
True | ||
>>> float('nan') is float('nan') |
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.
Not too happy about this example because I could see us change this behavior in the future to return the same NaN object.
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.
Not too happy about this example because I could see us change this behavior in the future to return the same NaN object.
I feel the same way, this example is confusing. This phenomenon is simply due to the differences in function implementations, not related to any standard.
Maybe we should omit the example about is
and just keep docs to remind users not use is
to check if a number is a NaN.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Thanks @CharlieZhao95 for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
GH-32263 is a backport of this pull request to the 3.10 branch. |
GH-32264 is a backport of this pull request to the 3.9 branch. |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 182e93c) Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 182e93c) Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
Documentation improvements for
math.nan
with following points:math.isnan(x)
to check whether a number is a NaN.https://bugs.python.org/issue47031