[Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.
Charles R Harris
charlesr.harris at gmail.com
Fri Oct 4 16:37:46 EDT 2013
I've made a PR for this. The commit message is
Deal with subclasses of ndarray, like pandas.Series and matrix.
Subclasses may not define the new keyword keepdims or deal
gracefully with ufuncs in all their forms. This is solved by
throwing the problem onto the np.sum, np.any, etc. functions
that have ugly hacks to deal with the problem.
Settle handling of all-nan slices.
nanmax, nanmin -- Raise warning, return NaN for slice.
nanargmax, nanargmin -- Raise ValueError.
nansum -- Return 0 for slice.
nanmean, nanvar, nanstd -- Raise warning, return NaN for slice.
Make NaN functions work for scalar arguments.
This may seem silly, but it removes a check for special cases.
Update tests
Deal with new all-nan handling.
Test with matrix class as example of subclass without keepdims.
Test with scalar arguments.
Note that 1.7 already raises a ValueError for nanarg{max, min} on account
of casting rules that don't allow nans to be cast to ints. This just makes
the same hold true for scalar returns.
If there are no objections, this will go into 1.9 as a starting point and
be backported to 1.8.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20131004/5f2a9ef5/attachment.html>
More information about the NumPy-Discussion
mailing list