On Wed, Oct 22, 2025 at 5:19 AM matti picus via NumPy-Discussion <
[email protected]> wrote:

> 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.
>

I think that's the direction that
https://github.com/data-apis/array-api/issues/621 is leaning in as well.


> 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.
>

The main advantage is that we can add that same keyword to more niche
reduction functions that we currently don't want as separate functions
because it bloats the namespace too much for limited gain. See for example
https://github.com/numpy/numpy/issues/13198 where we rejected adding
`nanptp`. A keyword is much more lightweight so won't run into the same
objection.

Cheers,
Ralf
_______________________________________________
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]

Reply via email to