[Numpy-discussion] how to use argsort result?
Stefan van der Walt
stefan at sun.ac.za
Tue Jul 11 06:10:53 CDT 2006
On Tue, Jul 11, 2006 at 12:37:23PM +0200, Pau Gargallo wrote:
> > Something's not quite right here. The argsort docstring states that:
> > argsort(a,axis=-1) return the indices into a of the sorted array
> > along the given axis, so that take(a,result,axis) is the sorted array.
> > But
> > N.take(A,A.argsort()) breaks. Either this is a bug, or the docstring
> > needs to be updated.
> > Cheers
> > Stéfan
> I think the docstring is wrong, because take doesn't do that.
> if you N.take(A,A.argsort(1), 1), it doesn't break but it doesn't sort
> A neither.
> Take seems to peek entire columns, but take's docstring is missing.
> For the argsort docstring, it may be usefull to indicate that if one do
> >>> ind = indices(A.shape)
> >>> ind[ax] = A.argsort(axis=ax)
> then A[ind] is the sorted array.
We can always adapt the documentation at
into a docstring. I'll file a ticket.
More information about the Numpy-discussion