8000 MAINT: Make the refactor suggested in prepare_index by eric-wieser · Pull Request #8278 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Make the refactor suggested in prepare_index #8278

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 11 commits into from
Jul 18, 2017
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
MAINT: Fix typo, remove unnecessary nesting
  • Loading branch information
eric-wieser committed Apr 8, 2017
commit bfd70c23b57ab278566f3503d9d93f20b0512281
17 changes: 7 additions & 10 deletions numpy/core/src/multiarray/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,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;
}

Copy link
Member

Choose a reason for hiding this comment

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

Just what I think right now (don't worry about it), but I would remove the blank line at least to make the else stick to the if block.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, since this was as much accidental as anything else

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