-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
argsort does not work for multidimensional arrays #4724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#advanced-indexing Try this:
|
I was confused in the same way. The documentation specifically states,
Which only applies to a 1D array. Should the documentation be extended to specify that this is not the case for ND arrays? |
@lzkelley Yes, a patch to improve the documentation would be very welcome. |
@shoyer cool, I'll make a PR for it and update |
DOC: clarify usage of 'argparse' return value (see #4724).
In response to Ticket numpy#4724, explain that the 'index_array' returned by 'argparse' can only be used to (directly) sort a one-dimensional input array.
It would be good if there were an example of how to actually use the output to sort the N-D array. It would also be good if there were a more readable solution than |
Maybe @seberg could make it one of his indexing function additions. |
I don't think it fits indexing very obviously, a pick function or so is probably an easier match. |
+1 for a new function. |
Isn't the entire purpose of |
|
This is #8708 |
consider the following code:
a = np.random.random([5,5])
ind = np.argsort(a, axis=1)
a_sorted = a[ind]
np.sort(a, axis=1)
now a_sorted and a should be both sorted along the 1-axis. However not even the shapes are identical anymore. a is still of (5,5) while a_sorted is (5,5,5). If this is the intended behaviour, can someone tell me why?
The text was updated successfully, but these errors were encountered: