[Numpy-discussion] Consider improving numpy.outer's behavior with zero-dimensional vectors
mistersheik at gmail.com
Tue Apr 14 15:48:48 EDT 2015
Yes, I totally agree with you regarding np.sum and np.product, which is why
I didn't suggest np.add.reduce, np.multiply.reduce. I wasn't sure whether
cumsum and cumprod might be on the line in your judgment.
On Tue, Apr 14, 2015 at 3:37 PM, Nathaniel Smith <njs at pobox.com> wrote:
> On Apr 14, 2015 2:48 PM, "Neil Girdhar" <mistersheik at gmail.com> wrote:
> > Okay, but by the same token, why do we have cumsum? Isn't it identical
> > np.add.accumulate
> > — or if you're passing in multidimensional data —
> > np.add.accumulate(a.flatten())
> > ?
> > add.accumulate feels more generic, would make the other ufunc things
> more discoverable, and is self-documenting.
> > Similarly, cumprod is just np.multiply.accumulate.
> Yeah, but these do have several differences than np.outer:
> - they get used much more
> - their definitions are less obviously broken (cumsum has no obvious
> definition for an n-d array so you have to pick one; outer does have an
> obvious definition and np.outer got it wrong)
> - they're more familiar from other systems (R, MATLAB)
> - they allow for special dispatch rules (e.g. np.sum(a) will try calling
> a.sum() before it tries coercing a to an ndarray, so e.g. on np.ma
> objects np.sum works and np.add.accumulate doesn't. Eventually this will
> perhaps be obviated by __numpy_ufunc__, but that is still some ways off.)
> So the situation is much less clear cut.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion