-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
DOC: argmin, argmax, argort, etc. should link to np.take_along_axis
in their documentation
#6078
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
Indeed, this problem has also flummoxed me. Here's the helper function I wrote, which may be slightly more interpretable: def argsort_indices(a, axis=-1):
"""Like argsort, but returns an index suitable for sorting the
the original array even if that array is multidimensional
"""
a = np.asarray(a)
ind = list(np.ix_(*[np.arange(d) for d in a.shape]))
ind[axis] = a.argsort(axis)
return tuple(ind) |
@shoyer - yours is definitely easier to read, in that it leaves the proper shaping to |
I guess it's less general in that it only works for |
I think it would be lot better than today's implementation if the np.unravel_index(np.argsort(a, axis=None), a.shape) |
As a rule, NumPy doesn't change existing behavior. So this will need to be new API of some sort. |
@shoyer Oh that's true. |
I think this issue is now irrelevant, since we have |
np.take_along_axis
in their documentation
In #6075, I wondered whether it might be possible to
and @jaimefrio suggested that it might be simpler to have
That indeed seems better, so I'm raising this as a separate issue. The code linked to above could be used as a template on how to generate the index tuple.
The text was updated successfully, but these errors were encountered: