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

Robert Kern robert.kern@gmail....
Mon Jun 1 19:30:02 CDT 2009


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.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list