* Sets a single item in the array, based on a single multi-index * array of values, which must be of length PyArray_NDIM(self). * * Returns 0 on success, -1 on failure. */
| 3082 | * Returns 0 on success, -1 on failure. |
| 3083 | */ |
| 3084 | NPY_NO_EXPORT int |
| 3085 | PyArray_MultiIndexSetItem(PyArrayObject *self, const npy_intp *multi_index, |
| 3086 | PyObject *obj) |
| 3087 | { |
| 3088 | int idim, ndim = PyArray_NDIM(self); |
| 3089 | char *data = PyArray_DATA(self); |
| 3090 | npy_intp *shape = PyArray_SHAPE(self); |
| 3091 | npy_intp *strides = PyArray_STRIDES(self); |
| 3092 | |
| 3093 | /* Get the data pointer */ |
| 3094 | for (idim = 0; idim < ndim; ++idim) { |
| 3095 | npy_intp shapevalue = shape[idim]; |
| 3096 | npy_intp ind = multi_index[idim]; |
| 3097 | |
| 3098 | if (check_and_adjust_index(&ind, shapevalue, idim, NULL) < 0) { |
| 3099 | return -1; |
| 3100 | } |
| 3101 | data += ind * strides[idim]; |
| 3102 | } |
| 3103 | |
| 3104 | return PyArray_Pack(PyArray_DESCR(self), data, obj); |
| 3105 | } |
no test coverage detected