All,
Let a & b be two ndarrays of the same shape. I'm trying to find the elements 
of b that correspond to the minima of a along an arbitrary axis.
The problem is trivial when axis=None or when a.ndim=2, but I'm getting 
confused with higher dimensions: I came to the following solution that looks 
rather ugly, and I'd need some ideas to simplify it

>>>a=numpy.arange(24).reshape(2,3,4)
>>>axis=-1
>>>b = numpy.rollaxis(a,axis,0)[a.argmin(axis)][tuple([0]*(a.ndim-1))]
>>>numpy.all(b, a.min(axis))
True

Thanks a lot in advance for any suggestions.


_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to