[Numpy-discussion] numpy.nansum() behavior in 1.3.0

Charles R Harris charlesr.harris@gmail....
Mon Jun 1 20:09:35 CDT 2009


On Mon, Jun 1, 2009 at 6:30 PM, Robert Kern <robert.kern@gmail.com> wrote:

> On Mon, Jun 1, 2009 at 18:50,  <josef.pktd@gmail.com> wrote:
> > On Mon, Jun 1, 2009 at 7:43 PM,  <josef.pktd@gmail.com> wrote:
>
> >> is np.size the right check for non-empty array, including subtypes?
>
> Yes.
>
> >> i.e.
> >>
> >> if y.size and mask.all():
> >>        return np.nan
> >>
> >> or more explicit
> >> if y.size > 0 and mask.all():
> >>        return np.nan
> >>
> >
> > Actually, now I think this is the wrong behavior, nansum should never
> > return nan.
> >
> >>>> np.nansum([np.nan, np.nan])
> > 1.#QNAN
> >
> > shouldn't this be zero
>
> I agree.
>

Would anyone be interested in ufuncs fadd/fsub that treated nans like zeros?
Note the fmax.reduce can be used the implement nanmax.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090601/03624055/attachment.html 


More information about the Numpy-discussion mailing list