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
MAINT: Fix typo, remove unnecessary nesting
  • Loading branch information
eric-wieser committed Apr 7, 2017
commit be959e85861665c3f4027705f625c07f5298f4fb
17 changes: 7 additions & 10 deletions numpy/core/src/multiarray/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,19 @@ prepare_index_tuple(PyObject *index)
}
}

/* If the index is not a tuple, conver it into (index,) */
/* If the index is not a tuple, convert it into (index,) */
if (!make_tuple && !PyTuple_CheckExact(index)) {
make_tuple = 1;
index_as_tuple = Py_BuildValue("(O)", index);
}
/* Otherwise, check if the tuple is too long */
else {
n = PyTuple_GET_SIZE(index_as_tuple);
if (n > NPY_MAXDIMS * 2) {
PyErr_SetString(PyExc_IndexError,
"too many indices for array");
if (make_tuple) {
Py_DECREF(index_as_tuple);
}
return NULL;
else if (PyTuple_GET_SIZE(index_as_tuple) > NPY_MAXDIMS * 2) {
PyErr_SetString(PyExc_IndexError,
"too many indices for array");
if (make_tuple) {
Py_DECREF(index_as_tuple);
}
return NULL;
}

/* if we didn't make a tuple, then we're creating another reference */
Expand Down
0