Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: Add flat examples to argmax and armgin #28826

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danra
Copy link

@danra danra commented Apr 25, 2025

No description provided.

@@ -1306,6 +1306,8 @@ def argmax(a, axis=None, out=None, *, keepdims=np._NoValue):

Indexes of the maximal elements of a N-dimensional array:

>>> a.flat[np.argmax(a)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a useful addition to the docs, but the example code does not match the text above (e.g. Indexes of the maximal elements of a N-dimensional array:). Maybe move this a bit down (after the a[ind] example)? Or rename the text to Indices and values of the maximal ...

Note: both Indexes and Indices are correct, but it is a bit inconsistent to have the docs of argmin and argmax use a different form.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to me like it could be a separate change. The addition just shows how to simply use the index without having to unravel it first; the raw form is used to actually to get the value, but that was already the case with the unraveled form. (and unlike the unraveled form, the raw index already appears above, so seemed to me like it's not worth repeating).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants