question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOC: argmin, argmax, argort, etc. should link to `np.take_along_axis` in their documentation

See original GitHub issue

In #6075, I wondered whether it might be possible to

to have some simple way to use the output of np.arg[min|max|sort] as a proper index (to avoid hackery as in https://github.com/astropy/astropy/blob/master/astropy/time/core.py#L896 – if there is a simpler way already, let me know!)

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.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ElieGouziencommented, May 11, 2017

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)
0reactions
sebergcommented, May 3, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

numpy.argmin — NumPy v1.24 Manual
Returns the indices of the minimum values along an axis. ... If this is set to True, the axes which are reduced are...
Read more >
numpy.argmin — NumPy v1.10 Manual
Returns the indices of the minimum values along an axis. Parameters: a : array_like. Input array. axis : int, optional.
Read more >
Feature request: Allow np.argmax to output top K maximum ...
Currently np.argmax, np.argmin, np.max and np.min return the maximum and minimum values respectively. numpy.argmax(a, axis=None, out=None)
Read more >
numpy.argmax() in Python - GeeksforGeeks
argmax () function returns indices of the max element of the array in a particular axis. Syntax : numpy.argmax(array, axis = None, out...
Read more >
Command for argmin or argmax? - TeX - LaTeX Stack Exchange
As Pieter pointed out, the correct way to define argmin and argmax operators in LaTeX is: \usepackage{amsmath} \DeclareMathOperator*{\argmax}{arg\,max} ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found