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

Charles R Harris via NumPy-Discussion <[email protected]>
Newsgroups gmane.comp.python.numeric.general
Message-ID <CAB6mnx+WRna2i10mVKf34t9yGQbAfH5ZsEDrWrJJmk_CzNtWtQ@mail.gmail.com>
On Fri, Oct 24, 2025 at 3:13 PM Marten van Kerkwijk via NumPy-Discussion <
[email protected]> wrote:

> Hi Carlos,
>
> Yes, good idea to add "where" wherever it makes sense -- indeed, that
> would be good even if we do not deprecate the nan-ignoring functions.
>
> As you noted, a version where one does isnan(data) actually costs less
> memory than the nan* functions, since those do ``isnan(data)`` too and,
> if any nan are present, the whole data array is copied, with nan
> replaced with appropriate fill values.
>
> Currently, the only way without chaning numpy code to avoid large arrays
> altogether is by having either a nan-aware data type (which can do the
> filling on the smaller chunks given by the iterator by having a
> promotor, or have custom loops for various functions).
>
> I wonder if we could short-circuit that to some extent, e.g., suppose we
> do have ``where`` generally, one could imagine having a special marker,
> e.g., used like ``where=np.NOT_NAN``, which would get special treatment
> used inside the reduction loops, in the same way the current code treats
> special-cases having a where array.  (One could even go further and
> allow passing in any ufunc to where, as long as it has an approriate
> data_type->bool loop.  But that's probably overdesigning it.)
>
> All the best,
>
>
Just to note that "where" was an artifact of the addition of masks to the
array type. When the mask implementation was abandoned we  kept "where"
because it was useful. Or so I recall.

Chuck

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