8000 ENH: Add index_tricks.as_index_tuple by eric-wieser · Pull Request #8276 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add index_tricks.as_index_tuple #8276

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

Closed
wants to merge 6 commits into from
Closed
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
DOC: Improve comments on prepare_index_tuple
  • Loading branch information
eric-wieser committed Apr 7, 2017
commit 431c33982940e0f6787dd395dcd4519296cf488f
13 changes: 9 additions & 4 deletions numpy/core/src/multiarray/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,20 @@ PyArray_MapIterSwapAxes(PyArrayMapIterObject *mit, PyArrayObject **ret, int getm
/**
* Prepare an index argument into a tuple
*
* The index might be a multi-dimensional index, but not yet a tuple
* this makes it a tuple in that case. This also promotes scalars to 1-tuples.
* This mainly implements the following section from the advanced indexing docs:
* > In order to remain backward compatible with a common usage in Numeric,
* > basic slicing is also initiated if the selection object is any non-ndarray
* > sequence (such as a list) containing slice objects, the Ellipsis object,
* > or the newaxis object, but not for integer arrays or other embedded
* > sequences.
*
* It is the callers repsonsibility to call Py_DECREF on a non-null result,
* even if it is the same as the input.
* This also promotes scalars to 1-tuples, and downcasts tuple subclasses
*
* @param the index object, which may or may not be a tuple
*
* @returns the index converted to a tuple, if possible, else NULL on an error
* It is the caller's responsibility to call Py_DECREF on a non-null
* result, even if it is the same as the input.
*/
NPY_NO_EXPORT PyObject *
prepare_index_tuple(PyObject *index)
Expand Down
0