Dimension reduction

David Huard david.huard at gmail.com
Thu Oct 19 12:01:37 CDT 2006

2006/10/19, Robert Kern <robert.kern at gmail.com>:

> 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
>>> a.sum(axis=1j)
>>> a.sum(axis=1)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061019/6c819797/attachment-0001.html 
-------------- next part --------------
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
-------------- next part --------------
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net

More information about the Numpy-discussion mailing list