You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DOC: argmin, argmax, argort, etc. should link to np.take_along_axis in their documentation #6078
and @jaimefrio suggested that it might be simpler to have
a make_me_an_indexing_tuple=False new keyword argument for the argxxx functions?
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.
Here's the helper function I wrote, which may be slightly more interpretable:
defargsort_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) fordina.shape]))
ind[axis] =a.argsort(axis)
returntuple(ind)
I think it would be lot better than today's implementation if the axis=None option returned something equivalent to :
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.
I think this issue is now irrelevant, since we have np.take_along_axis instead, which solves the issue. I will however transform it into a Documentation issue, since those functions should list it under the See Also section at least.
changed the title [-]Optional output of full fancy index for argmin, argmax, argort?[/-][+]DOC: argmin, argmax, argort, etc. should link to `np.take_along_axis` in their documentation[/+]on May 3, 2019
Activity
shoyer commentedon Jul 17, 2015
Indeed, this problem has also flummoxed me.
Here's the helper function I wrote, which may be slightly more interpretable:
mhvk commentedon Jul 17, 2015
@shoyer - yours is definitely easier to read, in that it leaves the proper shaping to
np.ix_... also, it doesn't deal withkeepdims, right?shoyer commentedon Jul 17, 2015
I guess it's less general in that it only works for
argsort-- I didn't think aboutmin/max, so I didn't need anything forkeepdims.ElieGouzien commentedon May 11, 2017
I think it would be lot better than today's implementation if the
axis=Noneoption returned something equivalent to :shoyer commentedon May 12, 2017
As a rule, NumPy doesn't change existing behavior. So this will need to be new API of some sort.
ElieGouzien commentedon Jun 29, 2017
@shoyer Oh that's true.
I've just submitted a pull request to add my proposition to the doc so that the user can easily find how to retrieve indices.
seberg commentedon May 3, 2019
I think this issue is now irrelevant, since we have
np.take_along_axisinstead, which solves the issue. I will however transform it into a Documentation issue, since those functions should list it under the See Also section at least.[-]Optional output of full fancy index for argmin, argmax, argort?[/-][+]DOC: argmin, argmax, argort, etc. should link to `np.take_along_axis` in their documentation[/+]