On Apr 14, 2015 2:48 PM, "Neil Girdhar" <mistersh...@gmail.com> wrote: > > Okay, but by the same token, why do we have cumsum? Isn't it identical to > > 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. -n
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion