<p dir="ltr">On 22 Mar 2013 14:09, &quot;Neal Becker&quot; &lt;<a href="mailto:ndbecker2@gmail.com">ndbecker2@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; I frequently find I have my 1d function that performs some reduction that I&#39;d<br>
&gt; like to apply-along some axis of an n-d array.<br>
&gt;<br>
&gt; As a trivial example,<br>
&gt;<br>
&gt; def sum(u):<br>
&gt; return np.sum (u)<br>
&gt;<br>
&gt; In this case the function is probably C/C++ code, but that is irrelevant (I<br>
&gt; think).<br>
&gt;<br>
&gt; Is there a reasonably efficient way to do this within numpy?</p>
<p dir="ltr">The core infrastructure for this sort of thing is there - search on &quot;generalized ufuncs&quot;. There&#39;s no python-level api as far as I know, though, yet.</p>
<p dir="ltr">You could write a reasonable facsimile of np.vectorize for such functions using nditer.</p>
<p dir="ltr">-n</p>