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
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
Update numpy/core/fromnumeric.py
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
  • Loading branch information
mproszewska and eric-wieser authored Nov 2, 2019
commit de02cd9585b94777b6910bf4671797a84f175548
3 changes: 2 additions & 1 deletion numpy/core/fromnumeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,8 @@ def argmax(a, axis=None, out=None):
1

>>> x = np.array([[4,2,3],[1,0,3]])
>>> np.take_along_axis(x, np.expand_dims(np.argmax(x, axis=-1), axis=-1), axis=-1) # same as `np.max(x, axis=-1, keepdims=True)`
>>> 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]])
>>> np.take_along_axis(x, np.expand_dims(index_array, axis=-1), axis=-1).squeeze(axis=-1) # same as np.max(x, axis=-1)
Expand Down
0