[Numpy-discussion] argmin & min on ndarrays

Anne Archibald peridot.faceted@gmail....
Tue Mar 4 18:21:14 CST 2008

On 04/03/2008, Pierre GM <pgmdevlist@gmail.com> wrote:
> Anne,
>  Thanks a lot for your suggestion. Something like
>  >>>if axis is None:
>  >>>    return b.flat[a.argmin()]
>  >>>else:
>  >>>   return numpy.choose(a.argmin(axis),numpy.rollaxis(b,axis,0))
>  seems to do the trick fairly nicely indeed. The other solutions you suggested
>  would require too much ad hoc adaptation.
>  Thanks again !

Ah! "It ain't the things you don't know that'll get you, it's the
things you know that ain't so." I thought rollaxis rolled the axes
around cyclically. This is much more useful, but what a funny name for
what it actually does...

I should have provided the link before, but this is very useful for
answering this kind of question:

Good luck,

More information about the Numpy-discussion mailing list