MCPcopy Create free account
hub / github.com/numpy/numpy / npyiter_reset

Function npyiter_reset

numpy/core/src/multiarray/nditer_pywrap.c:1193–1224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1191}
1192
1193static PyObject *
1194npyiter_reset(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
1195{
1196 if (self->iter == NULL) {
1197 PyErr_SetString(PyExc_ValueError,
1198 "Iterator is invalid");
1199 return NULL;
1200 }
1201
1202 if (NpyIter_Reset(self->iter, NULL) != NPY_SUCCEED) {
1203 return NULL;
1204 }
1205 if (NpyIter_GetIterSize(self->iter) == 0) {
1206 self->started = 1;
1207 self->finished = 1;
1208 }
1209 else {
1210 self->started = 0;
1211 self->finished = 0;
1212 }
1213
1214 if (self->get_multi_index == NULL && NpyIter_HasMultiIndex(self->iter)) {
1215 self->get_multi_index = NpyIter_GetGetMultiIndex(self->iter, NULL);
1216 }
1217
1218 /* If there is nesting, the nested iterators should be reset */
1219 if (npyiter_resetbasepointers(self) != NPY_SUCCEED) {
1220 return NULL;
1221 }
1222
1223 Py_RETURN_NONE;
1224}
1225
1226/*
1227 * Makes a copy of the iterator. Note that the nesting is not

Callers

nothing calls this directly

Calls 4

NpyIter_ResetFunction · 0.85
NpyIter_GetIterSizeFunction · 0.85
NpyIter_HasMultiIndexFunction · 0.85

Tested by

no test coverage detected