On 12/27/19 9:15 PM, Christopher Barker wrote:
I’m going to strongly support David Mertz’s point here:
It is a well known axiom of computing that returning an *incorrect*
result is a very bad thing.
There is also an axiom that you can only expect valid results if you
meet the operations pre-conditions.
Sometimes, being totally defensive in checking for 'bad' inputs costs
you too much performance.
The stated requirement on the statistics module is you feed it
'numbers', and a NaN is by definition Not a Number.
The Median function also implies that its inputs have the property of
having an order, as well as being able to be added (and if you can't add
them, then you need to use median_lower or median_upper)
I will also point out that really the median function is a small part of
the problem, all the x-tile based functions have the same issue, and
fundamentally it is a problem with sorted().
Has anyone tried to implement a version of these that checks for inputs
that don't have a total order and seen what the performance impact is?
Testing for NaNs isn't trivial, as elsewhere it was pointed out that how
you check is based on the type of the number you have (Decimals being
different from floats). To be really complete, you want to actually
detect that you have some elements that don't form a total order with
the other elements.
In many ways, half fixing the issue makes it worse, as improving
reliability can lead you to forget that you need to take care, so the
remaining issues catch you harder.
--
Richard Damon
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/O23NO3WK4EZABTR4XV3TLDK7KG2NPYOI/
Code of Conduct: http://python.org/psf/codeofconduct/