* Gets a single item from the array, based on a single multi-index * array of values, which must be of length PyArray_NDIM(self). */
| 3054 | * array of values, which must be of length PyArray_NDIM(self). |
| 3055 | */ |
| 3056 | NPY_NO_EXPORT PyObject * |
| 3057 | PyArray_MultiIndexGetItem(PyArrayObject *self, const npy_intp *multi_index) |
| 3058 | { |
| 3059 | int idim, ndim = PyArray_NDIM(self); |
| 3060 | char *data = PyArray_DATA(self); |
| 3061 | npy_intp *shape = PyArray_SHAPE(self); |
| 3062 | npy_intp *strides = PyArray_STRIDES(self); |
| 3063 | |
| 3064 | /* Get the data pointer */ |
| 3065 | for (idim = 0; idim < ndim; ++idim) { |
| 3066 | npy_intp shapevalue = shape[idim]; |
| 3067 | npy_intp ind = multi_index[idim]; |
| 3068 | |
| 3069 | if (check_and_adjust_index(&ind, shapevalue, idim, NULL) < 0) { |
| 3070 | return NULL; |
| 3071 | } |
| 3072 | data += ind * strides[idim]; |
| 3073 | } |
| 3074 | |
| 3075 | return PyArray_GETITEM(self, data); |
| 3076 | } |
| 3077 | |
| 3078 | /* |
| 3079 | * Sets a single item in the array, based on a single multi-index |
no test coverage detected