sum over all but one axis

Vincent Schut schut at sarvision.nl
Thu Oct 26 05:16:34 EDT 2006


Hi list,

probably I'm just missing something obvious, but I'm looking for a 
function/construcion to sum (or better, apply any numpy function) over 
all but one axis. Like when I have a nD array A, it will give me a 1D 
array with the sums of A[i, ...], but the axis that is retained in the 
result of course should be an argument to that function.
I thought 'apply_along_axis' would do the trick, but it does not. If I 
apply that to a 3d array, it results in a 2d array instead of a 1d array.

Of course I can easily loop over that axis, but if possible I'd like to 
prevent array loops...

Vincent.

-------------------------------------------------------------------------
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




More information about the NumPy-Discussion mailing list