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

Charles R Harris charlesr.harris at gmail.com
Mon Jun 1 21:09:35 EDT 2009


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

> On Mon, Jun 1, 2009 at 18:50,  <josef.pktd at gmail.com> wrote:
> > On Mon, Jun 1, 2009 at 7:43 PM,  <josef.pktd at 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.python.org/pipermail/numpy-discussion/attachments/20090601/03624055/attachment.html>


More information about the NumPy-Discussion mailing list