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

Function npyiter_multi_index_get

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

Source from the content-addressed store, hash-verified

1538}
1539
1540static PyObject *
1541npyiter_multi_index_get(NewNpyArrayIterObject *self, void *NPY_UNUSED(ignored))
1542{
1543 npy_intp ndim, multi_index[NPY_MAXDIMS];
1544
1545 if (self->iter == NULL || self->finished) {
1546 PyErr_SetString(PyExc_ValueError,
1547 "Iterator is past the end");
1548 return NULL;
1549 }
1550
1551 if (self->get_multi_index != NULL) {
1552 ndim = NpyIter_GetNDim(self->iter);
1553 self->get_multi_index(self->iter, multi_index);
1554 return PyArray_IntTupleFromIntp(ndim, multi_index);
1555 }
1556 else {
1557 if (!NpyIter_HasMultiIndex(self->iter)) {
1558 PyErr_SetString(PyExc_ValueError,
1559 "Iterator is not tracking a multi-index");
1560 return NULL;
1561 }
1562 else if (NpyIter_HasDelayedBufAlloc(self->iter)) {
1563 PyErr_SetString(PyExc_ValueError,
1564 "Iterator construction used delayed buffer allocation, "
1565 "and no reset has been done yet");
1566 return NULL;
1567 }
1568 else {
1569 PyErr_SetString(PyExc_ValueError,
1570 "Iterator is in an invalid state");
1571 return NULL;
1572 }
1573 }
1574}
1575
1576static int
1577npyiter_multi_index_set(

Callers

nothing calls this directly

Calls 4

NpyIter_GetNDimFunction · 0.85
PyArray_IntTupleFromIntpFunction · 0.85
NpyIter_HasMultiIndexFunction · 0.85

Tested by

no test coverage detected