[Numpy-discussion] howto apply-along-axis?

Nathaniel Smith njs at pobox.com
Fri Mar 22 10:21:03 EDT 2013

On 22 Mar 2013 14:09, "Neal Becker" <ndbecker2 at gmail.com> wrote:
> I frequently find I have my 1d function that performs some reduction that
> like to apply-along some axis of an n-d array.
> As a trivial example,
> def sum(u):
>   return np.sum (u)
> In this case the function is probably C/C++ code, but that is irrelevant
> think).
> Is there a reasonably efficient way to do this within numpy?

The core infrastructure for this sort of thing is there - search on
"generalized ufuncs". There's no python-level api as far as I know, though,

You could write a reasonable facsimile of np.vectorize for such functions
using nditer.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130322/a14f18a1/attachment.html>

More information about the NumPy-Discussion mailing list