[Numpy-discussion] [pydata] Re: [SciPy-Dev] 1.8.0rc1

Nathaniel Smith njs at pobox.com
Tue Oct 1 10:18:25 EDT 2013

On Tue, Oct 1, 2013 at 3:13 PM, Charles R Harris
<charlesr.harris at gmail.com> wrote:
> On Tue, Oct 1, 2013 at 7:58 AM, Nathaniel Smith <njs at pobox.com> wrote:
>> I bet the difference is:
>> In master, nansum ultimately calls arr.sum(...), which will be
>> intercepted by Series.sum.
>> In 1.8.x, nansum ultimately calls np.add.reduce(...), which can't be
>> intercepted and will return the wrong thing.
>> AFAICT the np.add.reduce(a, ...) call could just be replaced with
>> a.sum(...), but I might be missing something... surely there must have
>> been some reason it was written that way in the first place?
> No good reason, just a bit more efficient. The change for current master was
> because of the change in nansum behavior for empty slices. Changing the call
> to a.sum is not a problem, although I confess that it seems a bit fragile...

Yeah, ndarray subclassing is always fragile :-/. But hopefully
__numpy_ufunc__ will solve the problem in 1.9 and going forward...? (I
forget if it's implemented for .reduce yet.)

Filed a tracker bug here: https://github.com/numpy/numpy/issues/3849


More information about the NumPy-Discussion mailing list