Author steven.daprano
Recipients WarrenWeckesser, mark.dickinson, rhettinger, steven.daprano, tim.peters
Date 2019-10-07.01:41:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Thanks Warren, the resistance example is excellent, would you like to write up a PR to add it to the docs?

In the original design, I prohibited negative numbers because that seems to be what everyone says you should do, but as far as I can tell it is mathematically well defined so long as the sum of positive values doesn't equal the sum of negative values. And in that case, we could return a NAN.

I don't know that there's any physical meaning to the harmonic mean of negative values (circuits with negative resistances?), but I'm almost tempted to make this "consenting adults" and remove the restriction altogether. That would simplify the implementation and remove any arguments about early-out on zero.

I acknowledge Warren's point about permutations of data, but that applies to anything with an early-out. I don't think that's quite persuasive enough to justify losing the early exit on zero.

Warren, if you feel really strongly about this, feel free to try to change my mind. But for now, I think that documenting that zero triggers an early-out is the right solution.

By the way, I've just noticed that harmonic_mean([INF, INF]) raises. Should it return INF instead?
Date User Action Args
2019-10-07 01:41:18steven.dapranosetrecipients: + steven.daprano, tim.peters, rhettinger, mark.dickinson, WarrenWeckesser
2019-10-07 01:41:18steven.dapranosetmessageid: <>
2019-10-07 01:41:18steven.dapranolinkissue38382 messages
2019-10-07 01:41:18steven.dapranocreate