This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author joel.larose
Recipients joel.larose
Date 2021-06-10.01:54:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623290055.89.0.0955889494044.issue44370@roundup.psfhosted.org>
In-reply-to
Content
If `math.nan` is the first argument for either max() or min(), the result is always `nan`, regardless of the other values in the results.  However, if `nan` is in any other position in the arguments list, the result is always what you would expect if `nan` was not in the arguments list.

E.g.
from math import nan, inf

>>> max(nan, 5, 3, 0)
nan

>>> min(nan, 5, 3, 0)
nan

>>> min(nan, 5, 3, 0, inf, -inf)
nan

>>> max(nan, 5, 3, 0, inf, -inf)
nan

>>> max(inf, 5, 3, 0, nan, -inf)
inf

>>> max(8, inf, 5, 3, 0, nan, -inf)
inf

>>> min(8, inf, 5, 3, 0, nan, -inf)
-inf

>>> min(8, nan, inf, 5, 3, 0, nan, -inf)
-inf

>>> max(8, nan, inf, 5, 3, 0, nan, -inf)
inf

>>> max(8, 5, 3, 0, nan)
8

As you can see, the results for min() and max() are inconsistent for `nan` depending on whether it's the first argument or not.

I would prefer for min() and max() to ignore `nan` unless all arguments are `nan`.  However, the other path for consistent behaviour is to return `nan` if any of the arguments are `nan`.
History
Date User Action Args
2021-06-10 01:54:15joel.larosesetrecipients: + joel.larose
2021-06-10 01:54:15joel.larosesetmessageid: <1623290055.89.0.0955889494044.issue44370@roundup.psfhosted.org>
2021-06-10 01:54:15joel.laroselinkissue44370 messages
2021-06-10 01:54:15joel.larosecreate