Re: [Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread eat
Shailendra gmail.com> writes: > > Well, this is just a toy problem. argmax represent a method which will > give me a index in x[cond] . And for the case of multiple value my > requirement is fine with getting any "max" index. OK. My concern seems to be needless then. BTW, does this current th

Re: [Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread Shailendra
Well, this is just a toy problem. argmax represent a method which will give me a index in x[cond] . And for the case of multiple value my requirement is fine with getting any "max" index. Thanks, Shailendra On Fri, Apr 2, 2010 at 3:00 PM, eat wrote: > Shailendra gmail.com> writes: > >> >> I fo

Re: [Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread eat
Shailendra gmail.com> writes: > > I forgot to mention that i wanted this to work for general shape. So i > modified it little bit > > >>> x = array([[1,2,3,4,5], [6,7,8,7,6], [1,2,3,4,5]]) > >>> cond = (x > 5) > >>> loc= where(cond) > >>> arg_max=argmax(x[cond]) > >>> x[tuple([e[arg_max] for e

Re: [Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread Shailendra
I forgot to mention that i wanted this to work for general shape. So i modified it little bit >>> x = array([[1,2,3,4,5], [6,7,8,7,6], [1,2,3,4,5]]) >>> cond = (x > 5) >>> loc= where(cond) >>> arg_max=argmax(x[cond]) >>> x[tuple([e[arg_max] for e in loc])] 8 Thanks for your solution. Shailendra

Re: [Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread Robert Kern
On Fri, Apr 2, 2010 at 09:31, Shailendra wrote: > Hi All, > I have a following model problem. Let i have a array x > array([[1, 2, 3, 4, 5], >       [6, 7, 8, 7, 6], >       [1, 2, 3, 4, 5]]) > > suppose i apply some cond on it. cond= x>5 x[cond] > array([6, 7, 8, 7, 6]) > > Now, i

[Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread Shailendra
Hi All, I have a following model problem. Let i have a array >>> x array([[1, 2, 3, 4, 5], [6, 7, 8, 7, 6], [1, 2, 3, 4, 5]]) suppose i apply some cond on it. >>> cond= x>5 >>> x[cond] array([6, 7, 8, 7, 6]) Now, i want to argmax on this >>> max=argmax(x[cond]) >>> max 2 >>> x[cond]