Re: [Numpy-discussion] Nansum function behavior

2015-10-24 Thread Juan Nunez-Iglesias
Hi Charles, Just providing an outsider's perspective... Your specific use-case doesn't address the general definition of nansum: perform a sum while ignoring nans. As others have pointed out, (especially in the linked thread) the sum of nothing is 0. Although the current behaviour of

Re: [Numpy-discussion] Nansum function behavior

2015-10-23 Thread Robert Kern
On Fri, Oct 23, 2015 at 5:45 PM, Charles Rilhac wrote: > > Hello, > > I noticed the change regarding nan function and especially nansum function. I think this choice is a big mistake. I know that Matlab and R have made this choice but it is illogical and counterintuitive.

Re: [Numpy-discussion] Nansum function behavior

2015-10-23 Thread Benjamin Root
The change to nansum() happened several years ago. The main thrust of it was to make the following consistent: np.sum([]) # zero np.nansum([np.nan]) # zero np.sum([1]) # one np.nansum([np.nan, 1]) # one If you want to propagate masks and such, use masked arrays. Ben Root On Fri, Oct 23,

Re: [Numpy-discussion] Nansum function behavior

2015-10-23 Thread Stephan Hoyer
Hi Charles, You should read the previous discussion about this issue on GitHub: https://github.com/numpy/numpy/issues/1721 For what it's worth, I do think the new definition of nansum is more consistent. If you want to preserve NaN if there are no non-NaN values, you can often calculate this

Re: [Numpy-discussion] Nansum function behavior

2015-10-23 Thread Charles Rilhac
I saw this thread and I totally disagree with thouis argument… Of course, you can have NaN if there are only NaNs. Thanks goodness, There is a lot of way to do that. But it’s not convenient, consistent and above all, it is wrong logically to do that. NaN does not mean zeros and operation with

Re: [Numpy-discussion] Nansum function behavior

2015-10-23 Thread Charles Rilhac
Why do we keep this behaviour ? : np.nansum([np.nan]) # zero Firstly, you lose information. You can easily fill nan with zero after applying nansum but you cannot keep nan for nan-full rows if you doesn’t have a mask or keep the information about nan-full row before. It is not convenient,