Thanks Steven, for your thoughtful response.

On Thu, Dec 26, 2019 at 5:44 PM Steven D'Aprano <st...@pearwood.info> wrote:

> However, I am happy to accept that silent failure may not be the ideal
> result for everyone.


I would argue that it is not the ideal result for ANYONE. The only reason
for it is that it's easy to implement :-)

And it is a fact that NaNs are part of the what is probably the most
commonly used type with the statistics module: floats (and also Decimal,
probably third, after integers). Frankly, if statistics only supported
floats, it'd still be a very useful module.

This thread has gotten a bit distracted (it IS python-ideas, after all)
with discussion of sorting algorithms, and total ordering, and ..., but it
seems that all of that is secondary to deciding what NaNs should *mean* to
the statistics module. Options are:

A) A missing Value
B) An error of some sort.

If (A), then the functions should remove the NaNs from the data as (or
before) it is processed.
if (B) then they should either raise or return NaN

I think that missing value support would be a nice feature to have, so
propose to use NaNs that way. Of course, another option would be to have
the user set a flag indicating how they want NaN's treated (default TBD).

So that leaves us with how to detect a NaN. As Steven pointed out in
another thread, it's not trivially easy, but the smart folks on this list
can solve that, I'm sure. I notice that the module says this in the docs:

"Unless explicitly noted, these functions support int, float, Decimal and
Fraction. Behaviour with other types (whether in the numeric tower or not)
is currently unsupported"

So while it would be nice for a fully robust solution for any numeric type,
we should be able to get a good enough solution that at least supports the
built-in types.

(see the other thread Steven started for details).

-CHB

-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/XO7ZIJUJUYY3R3ZGVS7MDFRYANN5QXYA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to