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

Function npyiter_index_set

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

Source from the content-addressed store, hash-verified

1651}
1652
1653static int
1654npyiter_index_set(
1655 NewNpyArrayIterObject *self, PyObject *value, void *NPY_UNUSED(ignored))
1656{
1657 if (value == NULL) {
1658 PyErr_SetString(PyExc_AttributeError,
1659 "Cannot delete nditer index");
1660 return -1;
1661 }
1662 if (self->iter == NULL) {
1663 PyErr_SetString(PyExc_ValueError,
1664 "Iterator is invalid");
1665 return -1;
1666 }
1667
1668 if (NpyIter_HasIndex(self->iter)) {
1669 npy_intp ind;
1670 ind = PyLong_AsLong(value);
1671 if (error_converting(ind)) {
1672 return -1;
1673 }
1674 if (NpyIter_GotoIndex(self->iter, ind) != NPY_SUCCEED) {
1675 return -1;
1676 }
1677 self->started = 0;
1678 self->finished = 0;
1679
1680 /* If there is nesting, the nested iterators should be reset */
1681 if (npyiter_resetbasepointers(self) != NPY_SUCCEED) {
1682 return -1;
1683 }
1684
1685 return 0;
1686 }
1687 else {
1688 PyErr_SetString(PyExc_ValueError,
1689 "Iterator does not have an index");
1690 return -1;
1691 }
1692}
1693
1694static PyObject *
1695npyiter_iterindex_get(NewNpyArrayIterObject *self, void *NPY_UNUSED(ignored))

Callers

nothing calls this directly

Calls 3

NpyIter_HasIndexFunction · 0.85
NpyIter_GotoIndexFunction · 0.85

Tested by

no test coverage detected