[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

Mark Dickinson report at bugs.python.org
Wed Oct 9 06:27:20 EDT 2019


Mark Dickinson <dickinsm at gmail.com> added the comment:

> In [20]: harmonic_mean([math.nan, 0])                                           
> Out[20]: 0

That one seems excusable, for the same sort of reasons that IEEE 754 specifies that hypot(nan, inf) is inf rather than nan. Similarly, sumSquare and sumAbs from IEEE 754-2008 specify that infinities take precedence over NaNs, on the basis that the result doesn't change if the nan is replaced with any non-nan value.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38382>
_______________________________________


More information about the Python-bugs-list mailing list