[Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

Charles R Harris charlesr.harris at gmail.com
Thu Oct 3 07:56:31 EDT 2013


On Thu, Oct 3, 2013 at 4:06 AM, Daniele Nicolodi <daniele at grinta.net> wrote:

> Hello,
>
> sorry, I don't know where exactly jump in in the thread, it is getting
> quite long and articulated...
>
> On 02/10/2013 21:19, Charles R Harris wrote:
> > The main problem I had was deciding what arg{max, min} should return as
> > the return value is an integer. I like your suggestion of returning 0.
>
> What about returning -1? It is still an integer (on my numpy version the
> return value is a signed integer), it still has the property that
> a[np.argmin(a)] == nan for a of only nans, but it is easily identifiable
> as an anomalous return value if needed.
>

The problem is that -1 is a valid index, whereas intp.min will always be
out of range and lead to an IndexError if used.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20131003/e77e0d12/attachment.html>


More information about the NumPy-Discussion mailing list