Author rhettinger
Recipients WarrenWeckesser, mark.dickinson, rhettinger, steven.daprano, tim.peters
Date 2019-10-06.19:06:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570388766.52.0.229148224466.issue38382@roundup.psfhosted.org>
In-reply-to
Content
Normally early-out behaviors are allowed to skip any checks for subsequent inputs (for example, the any() and all() builtins stop consuming inputs one a final value is found).

However, that reasoning might not apply to a zero input for harmonic_mean().  Technically, the definition of harmonic mean doesn't allow for a zero input value at all (accordingly, MS Excel gives an error for a zero input).  Presumably, the reason that Python's harmonic_mean() returns zero is so that the function degrades gracefully as one of the inputs gets closer to zero.

Options at this point:

* Just document that there is an early-out for zero.

* Stick with the strategy of treating zero as if it were just a very, very small positive input.  The would imply that all of the inputs should be considered and that TypeErrors or StatisticErrors should be raised for later data points (though I'm unclear what this world view implies when the inputs have both a zero and a positive infinity).

* Treat a zero input as an error.  This matches the usual specification of harmonic mean being defined only for non-negative real inputs.
History
Date User Action Args
2019-10-06 19:06:06rhettingersetrecipients: + rhettinger, tim.peters, mark.dickinson, steven.daprano, WarrenWeckesser
2019-10-06 19:06:06rhettingersetmessageid: <1570388766.52.0.229148224466.issue38382@roundup.psfhosted.org>
2019-10-06 19:06:06rhettingerlinkissue38382 messages
2019-10-06 19:06:06rhettingercreate