On Thu, Aug 19, 2010 at 10:12 AM, Angus McMorland <[email protected]> wrote:
> Another rank-generic approach is to use apply_over_axes (you get a
> different shape to the result this way):
>
> a = np.random.randint(20, size=(4,3,5))
> b = np.apply_over_axes(np.sum, a, [1,2]).flat
> assert( np.all( b == a.sum(axis=2).sum(axis=1) ) )
>

Thanks for the responses!  This looks like what I've been looking for.
There's really a lot to numpy.  It's very powerful and I feel like
I've only scratched the surface.
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to