[Numpy-discussion] Strange behavior for argsort() and take()
Stéfan van der Walt
Wed Jun 18 11:53:23 CDT 2008
2008/6/18 Anne Archibald <email@example.com>:
> In : x.take(x.argsort())
> Out: array([ 0. , 0.1, 0.2, 0.3])
> If you would like to think of it more mathematically, when you feed
> np.argsort() an array that represents a permutation of the numbers
> 0,1,...,n-1, you get back the inverse permutation. When you pass a
> permutation as the argument to x.take(), you apply the permutation to
> x. (You can also invert a permutation by feeding it as indices to
> I have been tempted to write some support functions for manipulating
> permutations, but I'm not sure how generally useful they would be.
Do we have an easy way of grabbing the elements out of an array that
argmax(x, axis) ?
`take` won't do the job; there `axis` has a different meaning.
More information about the Numpy-discussion