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
4 changes: 4 additions & 0 deletions numpy/core/fromnumeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ def argpartition(a, kth, axis=-1, kind='introselect', order=None):
partition : Describes partition algorithms used.
ndarray.partition : Inplace partition.
argsort : Full indirect sort
take_along_axis : Take values from the input array by matching 1d index and data slices.
Copy link
Member
@eric-wieser eric-wieser Oct 29, 2019

Choose a reason for hiding this comment

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

Let's see how another maintainer feels about this first, but perhaps:

Suggested change
take_along_axis : Take values from the input array by matching 1d index and data slices.
take_along_axis : Apply ``index_array`` from argpartition to an array as if by calling partition

And same for the below,

    take_along_axis : Apply ``index_array`` from argsort to an array as if by calling sort
    take_along_axis : Apply ``np.expand_dims(index_array, axis)`` from argmin to an array as if by calling min
    take_along_axis : Apply ``np.expand_dims(index_array, axis)`` from argmax to an array as if by calling max

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably those use cases are worth mentioning, but I wasn't sure if the "See also" section is a right place for that. e.g. argsort and argpartition refer to take_along_axis in "Returns". Perhaps it's better to just add an example.

Copy link
Member

Choose a reason for hiding this comment

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

An example for each of these showing how to use take_along_axis would be great, if you're willing to spend the time. If not, we can merge this as is, and leave the issue open for someone else to add the examples.

Copy link
Member

Choose a reason for hiding this comment

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

"See Also" seems appropriate here.


Notes
-----
Expand Down Expand Up @@ -1025,6 +1026,7 @@ def argsort(a, axis=-1, kind=None, order=None):
lexsort : Indirect stable sort with multiple keys.
ndarray.sort : Inplace sort.
argpartition : Indirect partial sort.
take_along_axis : Take values from the input array by matching 1d index and data slices.

Notes
-----
Expand Down Expand Up @@ -1120,6 +1122,7 @@ def argmax(a, axis=None, out=None):
ndarray.argmax, argmin
amax : The maximum value along a given axis.
unravel_index : Convert a flat index into an index tuple.
take_along_axis : Take values from the input array by matching 1d index and data slices.

Notes
-----
Expand Down Expand Up @@ -1189,6 +1192,7 @@ def argmin(a, axis=None, out=None):
ndarray.argmin, argmax
amin : The minimum value along a given axis.
unravel_index : Convert a flat index into an index tuple.
take_along_axis : Take values from the input array by matching 1d index and data slices.

Notes
-----
Expand Down
0