On Sun, Dec 29, 2019, 9:50 AM Steven D'Aprano <st...@pearwood.info> wrote:

> On Sun, Dec 29, 2019 at 08:22:49AM -0500, David Mertz wrote:
> > Signalling NaN's are a pain because I'd want:
> >
> > is_nan(snan) == True
> >
> > But statistics.median([1, 2, snan], on_nan='ignore') to raise an
> exception.
>
> So you want to skip quiet NANs and raise on signalling NANs? I'd like to
> understand the use-case here. I guess it is "signalling NANs are an error,
> quiet NANs are missing data". Am I right?
>

Yes. Exactly! That seems to match the intention of IEEE-754.

How are the signalling NANs going to get into your data?
> As far as I know, there are no operations in Python which will naturally
> return a signalling NAN, you have to inject them into the data yourself:
>

But yes, the behavior with signalling NaNs is almost moot. There is
absolutely no "natural" way to get them in Python. So if someone does all
that work just to get behavior that is pedantically incorrect, I guess I
don't actually care.

In contrast, getting quiet NaNs really isnt that hard. Asymptotes easily
enough get you infinities that you didn't expect. And combining infinities
gets you NaNs.

For better or worse, numeric array libraries, NumPy, Pandas, and PyTorch,
use NaNs consistently for data that just wasn't available to start with,
not only for a calculation gone wonky. If you control the whole pipeline in
plain Python, None might be a better "missing" value. But these other tools
are pretty common.
_______________________________________________
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/OKZ6YOTAHSPAGQVFPRLTJQRGFQ5JRKBT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to