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

Raymond Hettinger report at bugs.python.org
Tue Oct 29 20:42:20 EDT 2019


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Maybe we should hold-off on adding negative number support unless a compelling use case arises.  It is telling that scipy.stats.hmean() and that MS Excel's harmean() haven't found justification to add negative number support.

In all likelihood, a negative input is an error in the input and users would be better-off seeing an exception raised.  In a number of contexts, the negative input wouldn't make sense all:

* a 10 ohm resistor wired in parallel with a negative 5 ohm resistor
* travel 1 km at 5 kph then another 1 km at -10 kph

We really don't have to go down this route just because we can.  The usual rule is to keep the API minimal unless real use cases arise to inform the design.

----------

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


More information about the Python-bugs-list mailing list