[issue47031] math.nan should note that NANs do not compare equal to anything

2022-04-02 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: Thanks for the bug report and patch! -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-04-02 Thread miss-islington
miss-islington added the comment: New changeset 5b80031fb0d2ea14f0d42a33309ce5464c4a6042 by Miss Islington (bot) in branch '3.9': bpo-47031: Improve documentation for `math.nan` (GH-32170) https://github.com/python/cpython/commit/5b80031fb0d2ea14f0d42a33309ce5464c4a6042 --

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-04-02 Thread miss-islington
miss-islington added the comment: New changeset 319a70cf99c9866c7fa47deecf04f6ebcfe35a54 by Miss Islington (bot) in branch '3.10': bpo-47031: Improve documentation for `math.nan` (GH-32170) https://github.com/python/cpython/commit/319a70cf99c9866c7fa47deecf04f6ebcfe35a54 --

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-04-02 Thread miss-islington
Change by miss-islington : -- pull_requests: +30329 pull_request: https://github.com/python/cpython/pull/32264 ___ Python tracker ___

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-04-02 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 7.0 -> 8.0 pull_requests: +30328 pull_request: https://github.com/python/cpython/pull/32263 ___ Python tracker

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-04-02 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: New changeset 182e93c3f57b0c72e765c9896066d32e461c0865 by Charlie Zhao in branch 'main': bpo-47031: Improve documentation for `math.nan` (GH-32170) https://github.com/python/cpython/commit/182e93c3f57b0c72e765c9896066d32e461c0865 -- nosy:

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-29 Thread Charlie Zhao
Charlie Zhao added the comment: I started a PR and some simple examples were added. It is helpful for those who are new to IEEE-754. According to Jelle's comments, the behavior of `float('nan') is float('nan')` may be changed in the future, so I just omit it and suggest users to use

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-28 Thread Charlie Zhao
Change by Charlie Zhao : -- keywords: +patch pull_requests: +30248 stage: -> patch review pull_request: https://github.com/python/cpython/pull/32170 ___ Python tracker ___

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-24 Thread Stanley
Stanley added the comment: Then perhaps saying that it's *never* equal is too strong, and instead we just say it's *not* equal. Not too sure how to phrase the behavior difference between `==` and `is` though, if that's something that should be noted. --

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: > We cannot guarantee that NAN never equal to anything, because we can > create an object equal to it. For example mock.ANY Sure. I don't expect that mock.ANY or other weird objects should obey the IEEE-754 rules. But we're talking numeric comparisons

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-24 Thread Charlie Zhao
Charlie Zhao added the comment: > "Due to the requirements of the `IEEE-754 standard > `_, math.nan and float('nan') are > never equal to any other value, including themselves. Use math.isnan to test > for NANs." It seems to me, Steven's description

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-20 Thread Stanley
Stanley added the comment: Vedran's got a good point, as existing documentation for math.nan already says "... Equivalent to the output of float('nan')." so it does seem a bit redundant to say both, though I wonder if we should still be explicit since >>> import math >>> math.nan is

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: We cannot guarantee that NAN never equal to anything, because we can create an object equal to it. For example mock.ANY. -- nosy: +serhiy.storchaka ___ Python tracker

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-19 Thread Vedran Čačić
Vedran Čačić added the comment: I'm not satisfied with "and" formulation. For all practical purposes, math.nan is the "same" object as float('nan'), they just represent two ways of referring to it (or constructing it). To me it sounds a bit like "2 and 1+1 are the only even prime numbers." I

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-18 Thread Stanley
Stanley added the comment: How does this sound instead? The unequalness is pushed to the front and the IEEE part back so it's less likely missed: Math.nan and float('nan') are never equal to any other value, including themselves, as per IEEE 754. Use math.isnan to test for NANs. --

[issue47031] math.nan should note that NANs do not compare equal to anything

2022-03-15 Thread Steven D'Aprano
New submission from Steven D'Aprano : The IEEE-754 requirement that NANs are never equal to anything, even to themselves, is a common stumbling block for those new to the consequences of IEEE-754. See for example #47020. The documentation for math.nan would be a good place to add a note like