8000 MAINT: remove unused parse_index() · shoyer/numpy@0b1caec · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b1caec

Browse files
committed
MAINT: remove unused parse_index()
* parse_index() has been completely unused in our code base for more than 5 years, with final removal in commit hash 607863d * this commit removes both the C function and its header file prototype declaration; there were no unit tests for this function
1 parent c0d4c74 commit 0b1caec

File tree

2 files changed

+0
-119
lines changed

2 files changed

+0
-119
lines changed

numpy/core/src/multiarray/iterators.c

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -92,114 +92,6 @@ parse_index_entry(PyObject *op, npy_intp *step_size,
9292
}
9393

9494

95-
/*
96-
* Parses an index that has no fancy indexing. Populates
97-
* out_dimensions, out_strides, and out_offset.
98-
*/
99-
NPY_NO_EXPORT int
100-
parse_index(PyArrayObject *self, PyObject *op,
101-
npy_intp *out_dimensions,
102-
npy_intp *out_strides,
103-
npy_intp *out_offset,
104-
int check_index)
105-
{
106-
int i, j, n;
107-
int nd_old, nd_new, n_add, n_ellipsis;
108-
npy_intp n_steps, start, offset, step_size;
109-
PyObject *op1 = NULL;
110-
int is_slice;
111-
112-
if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {
113-
n = 1;
114-
op1 = op;
115-
Py_INCREF(op);
116-
/* this relies on the fact that n==1 for loop below */
117-
is_slice = 1;
118-
}
119-
else {
120-
if (!PySequence_Check(op)) {
121-
PyErr_SetString(PyExc_IndexError,
122-
"index must be either an int "
123-
"or a sequence");
124-
return -1;
125-
}
126-
n = PySequence_Length(op);
127-
is_slice = 0;
128-
}
129-
130-
nd_old = nd_new = 0;
131-
132-
offset = 0;
133-
for (i = 0; i < n; i++) {
134-
if (!is_slice) {
135-
op1 = PySequence_GetItem(op, i);
136-
if (op1 == NULL) {
137-
return -1;
138-
}
139-
}
140-
start = parse_index_entry(op1, &step_size, &n_steps,
141-
nd_old < PyArray_NDIM(self) ?
142-
PyArray_DIMS(self)[nd_old] : 0,
143-
nd_old, check_index ?
144-
nd_old < PyArray_NDIM(self) : 0);
145-
Py_DECREF(op1);
146-
if (start == -1) {
147-
break;
148-
}
149-
if (n_steps == NEWAXIS_INDEX) {
150-
out_dimensions[nd_new] = 1;
151-
out_strides[nd_new] = 0;
152-
nd_new++;
153-
}
154-
else if (n_steps == ELLIPSIS_INDEX) {
155-
for (j = i + 1, n_ellipsis = 0; j < n; j++) {
156-
op1 = PySequence_GetItem(op, j);
157-
if (op1 == Py_None) {
158-
n_ellipsis++;
159-
}
160-
Py_DECREF(op1);
161-
}
162-
n_add = PyArray_NDIM(self)-(n-i-n_ellipsis-1+nd_old);
163-
if (n_add < 0) {
164-
PyErr_SetString(PyExc_IndexError, "too many indices");
165-
return -1;
166-
}
167-
for (j = 0; j < n_add; j++) {
168-
out_dimensions[nd_new] = PyArray_DIMS(self)[nd_old];
169-
out_strides[nd_new] = PyArray_STRIDES(self)[nd_old];
170-
nd_new++; nd_old++;
171-
}
172-
}
173-
else {
174-
if (nd_old >= PyArray_NDIM(self)) {
175-
PyErr_SetString(PyExc_IndexError, "too many indices");
176-
return -1;
177-
}
178-
offset += PyArray_STRIDES(self)[nd_old]*start;
179-
nd_old++;
180-
if (n_steps != SINGLE_INDEX) {
181-
out_dimensions[nd_new] = n_steps;
182-
out_strides[nd_new] = step_size *
183-
PyArray_STRIDES(self)[nd_old-1];
184-
nd_new++;
185-
}
186-
}
187-
}
188-
if (i < n) {
189-
return -1;
190-
}
191-
n_add = PyArray_NDIM(self)-nd_old;
192-
for (j = 0; j < n_add; j++) {
193-
out_dimensions[nd_new] = PyArray_DIMS(self)[nd_old];
194-
out_strides[nd_new] = PyArray_STRIDES(self)[nd_old];
195-
nd_new++;
196-
nd_old++;
197-
}
198-
*out_offset = offset;
199-
return nd_new;
200-
}
201-
202-
20395
/*********************** Element-wise Array Iterator ***********************/
20496
/* Aided by Peter J. Verveer's nd_image package and numpy's arraymap ****/
20597
/* and Python's array iterator ***/

numpy/core/src/multiarray/iterators.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
#ifndef _NPY_ARRAYITERATORS_H_
22
#define _NPY_ARRAYITERATORS_H_
33

4-
/*
5-
* Parses an index that has no fancy indexing. Populates
6-
* out_dimensions, out_strides, and out_offset.
7-
*/
8-
NPY_NO_EXPORT int
9-
parse_index(PyArrayObject *self, PyObject *op,
10-
npy_intp *out_dimensions,
11-
npy_intp *out_strides,
12-
npy_intp *out_offset,
13< 502F /td>-
int check_index);
14-
154
NPY_NO_EXPORT PyObject
165
*iter_subscript(PyArrayIterObject *, PyObject *);
176

0 commit comments

Comments
 (0)
0