Re: Replace nan-ignoring functions with an ignore_nan flag to their normal counterparts

matti picus via NumPy-Discussion <[email protected]>
Newsgroups gmane.comp.python.numeric.general
Message-ID <CAO8bCgjWTXbQiD4Q5PQFH1K5roOFw6rsK_Jc8qj-Xy9CxZHOrA@mail.gmail.com>
On Wed, Oct 22, 2025 at 6:04 AM Carlos Martin <[email protected]>
wrote:

> NumPy has the following nan-ignoring functions:
>
> ...
> Suggestion: Replace these functions with an ignore_nan flag to their
> normal counterparts. This avoids having entirely separate functions just to
> filter out nans, and shrinks the size of the codebase. It is also more
> user-friendly: it is simpler and easier to toggle a boolean flag.
>
> This has been briefly suggested before:
>
> -
> https://mail.python.org/archives/list/[email protected]/message/FQ362NGJLOJFN3BCJVST5TAQZCVWZTNO/
> - https://github.com/numpy/numpy/pull/25474#issuecomment-1868484678
>
> As mentioned in links, SciPy has a well-defined nan_policy kwarg. If we
are to change this I think we should discuss adopting that policy
https://docs.scipy.org/doc/scipy/dev/api-dev/nan_policy.html. We may need
to keep the current functions around for a while as aliases. I am not sure
about the advantages other than consistency with SciPy (which is no small
thing). I doubt it will shrink the size of the codebase significantly, and
using the named functions explicitly is just as easy as adding a kwarg. It
might however be easier to teach.
Matti

_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.