[Numpy-discussion] Getting index of array after applying cond
Fri Apr 2 14:44:16 CDT 2010
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.
On Fri, Apr 2, 2010 at 3:00 PM, eat <email@example.com> wrote:
> Shailendra <shailendra.vikas <at> 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 in loc])]
> But what happens if your x is for example
> x = array([[1,2,3,4,5], [6,8,8,8,6], [1,2,3,4,5]])
> x[tuple([e[arg_max] for e in loc])]
> would still yield to 8,
> which may or may not be an acceptable answer.
> Basically what I mean is that why to bother with the argmax at all,
> if your only interest is x[cond].max()?
> Just my 2 cents.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion