Re: [Numpy-discussion] return index of maximum value in an array easily?

2013-01-11 Thread Nathaniel Smith
On Thu, Jan 10, 2013 at 9:40 AM, Chao YUE chaoyue...@gmail.com wrote: Dear all, Are we going to consider returning the index of maximum value in an array easily without calling np.argmax and np.unravel_index consecutively? This does seem like a good thing to support somehow. What would a

Re: [Numpy-discussion] return index of maximum value in an array easily?

2013-01-11 Thread Sebastian Berg
On Sat, 2013-01-12 at 00:26 +0100, Chao YUE wrote: Hi, I don't know how others think about this. Like you point out, one can use np.nonzero(a==np.max(a)) as a workaround. For the second point, in case I have an array: a = np.arange(24.).reshape(2,3,4) suppose I want to find the

[Numpy-discussion] return index of maximum value in an array easily?

2013-01-10 Thread Chao YUE
Dear all, Are we going to consider returning the index of maximum value in an array easily without calling np.argmax and np.unravel_index consecutively? I saw few posts in mailing archive and stackover flow on this, when I tried to return the index of maximum value of 2d array. It seems that I

Re: [Numpy-discussion] return index of maximum value in an array easily?

2013-01-10 Thread Hanno Klemm
Hi Chao, in two dimensions the following works very well: In [97]: a = np.random.randn(5,7) In [98]: a[divmod(a.argmax(), a.shape[1])] Out[98]: 1.3680204597100922 In [99]: a.max() Out[99]: 1.3680204597100922 In [100]: In [100]: b = a[divmod(a.argmax(), a.shape[1])] In [101]: b==a.max()