[Numpy-discussion] What should be the value of nansum of nan's?

Warren Weckesser warren.weckesser@enthought....
Wed Apr 28 11:22:16 CDT 2010


Travis Oliphant wrote:
>
> On Apr 26, 2010, at 12:03 PM, Charles R Harris wrote:
>
>>
>>
>> On Mon, Apr 26, 2010 at 10:55 AM, Charles R Harris 
>> <charlesr.harris@gmail.com <mailto:charlesr.harris@gmail.com>> wrote:
>>
>>     Hi All,
>>
>>     We need to make a decision for ticket #1123
>>     <http://projects.scipy.org/numpy/ticket/1123#comment:11>
>>     regarding what nansum should return when all values are nan. At
>>     some earlier point it was zero, but currently it is nan, in fact
>>     it is nan whatever the operation is. That is consistent, simple
>>     and serves to mark the array or axis as containing all nans. I
>>     would like to close the ticket and am a bit inclined to go with
>>     the current behaviour although there is an argument to be made
>>     for returning 0 for the nansum case. Thoughts?
>>
>>
>> To add a bit of context, one could argue that the results should be 
>> consistent with the equivalent operations on empty arrays and always 
>> be non-nan.
>>
>> In [1]: nansum([])
>> Out[1]: nan
>>
>> In [2]: sum([])
>> Out[2]: 0.0
>
>
> I favor nansum([])  returning 0.0 which implies returning 0.0 when all 
> the elements are nan.
>

+1

> -Travis
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>   



More information about the NumPy-Discussion mailing list