2006/10/19, Robert Kern <[EMAIL PROTECTED]>:
def nonreducing_reducer(reducing_func, arr, axis):
     reduced = reducing_func(arr, axis=axis)
     shape = list(reduced.shape)
     axis = axis % len(arr.shape)
     shape.insert(axis, 1)
     reduced.shape = tuple(shape)
     return reduced

Cute !

Here is another one:
1dfunc = lambda x: atleast_1d(reducing_function(x))
apply_along_axis(1dfunc, axis, arr)

Is it something people often need ? Would it be worth, (for numpy 1.1 ?), to consider complex axis arguments as a wish to preserve the rank of the array?
>>> a.shape
(n,m,o,p)
>>> a.sum(axis=1j)
(n,1,o,p)
>>> a.sum(axis=1)
(n,o,p)

Thanks,

David

 

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to