8000 DOC: Add take_along_axis to the see also section in argmin, argmax etc. by mproszewska · Pull Request #14799 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: Add take_along_axis to the see also section in argmin, argmax etc. #14799

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

Merged
merged 18 commits into from
Nov 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tabs.
  • Loading branch information
mproszewska committed Nov 3, 2019
commit a292393aa6569affb84b838ed75cca3a172a6df7
6 changes: 3 additions & 3 deletions numpy/core/fromnumeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def argpartition(a, kth, axis=-1, kind='introselect', order=None):
>>> index_array = np.argpartition(x, kth=1, axis=-1)
>>> np.take_along_axis(x, index_array, axis=-1) # same as np.partition(x, kth=1)
array([[2, 3, 4],
[1, 1, 3]])
[1, 1, 3]])

"""
return _wrapfunc(a, 'argpartition', kth, axis=axis, kind=kind, order=order)
Expand Down Expand Up @@ -1169,7 +1169,7 @@ def argmax(a, axis=None, out=None):
>>> index_array = np.argmax(x, axis=-1)
>>> np.take_along_axis(x, np.expand_dims(index_array, axis=-1), axis=-1) # same as np.max(x, axis=-1, keepdims=True)
array([[4],
[3]])
[3]])
>>> np.take_along_axis(x, np.expand_dims(index_array, axis=-1), axis=-1).squeeze(axis=-1) # same as np.max(x, axis=-1)
array([4, 3])

Copy link
Member

Choose a reason for hiding this comment

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

These lines are quite long. Maybe move the comment to stand alone in the line above the code

Expand Down Expand Up @@ -1247,7 +1247,7 @@ def argmin(a, axis=None, out=None):
>>> index_array = np.argmin(x, axis=-1)
>>> np.take_along_axis(x, np.expand_dims(index_array, axis=-1), axis=-1) # same as np.min(x, axis=-1, keepdims=True)
array([[2],
[0]])
[0]])
>>> np.take_along_axis(x, np.expand_dims(index_array, axis=-1), axis=-1).squeeze(axis=-1) # same as np.max(x, axis=-1)
Copy link
Member
@eric-wieser eric-wieser Nov 3, 2019

Choose a reason for hiding this comment

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

Nit: pep8 wants two spaces before #, same on other lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I was looking for that bug

array([2, 0])

Expand Down
0