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]
