[Numpy-discussion] Bug in ndarray.argmax

Pierre Barbier de Reuille p.barbier-de-reuille at uea.ac.uk
Mon May 1 07:34:06 EDT 2006


Hello,

I notices a bug in ndarray.argmax which prevent from getting the argmax
from any axis but the last one.
I join a patch to correct this.
Also, here is a small python code to test the behaviour of argmax I
implemented :

==8<====8<====8<====8<====8<====8<====8<====8<===8<===

from numpy import array, random, all

a = random.normal( 0, 1, ( 4,5,6,7,8 ) )
for i in xrange( a.ndim ):
  amax = a.max( i )
  aargmax = a.argmax( i )
  axes = range( a.ndim )
  axes.remove( i )
  assert all( amax == aargmax.choose( *a.transpose( i, *axes ) ) )

==8<====8<====8<====8<====8<====8<====8<====8<===8<===

Pierre
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: swapback.patch
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060501/7279ef11/attachment.ksh>


More information about the NumPy-Discussion mailing list