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

Function iter_coords_get

numpy/core/src/multiarray/iterators.c:1077–1100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1075}
1076
1077static PyObject *
1078iter_coords_get(PyArrayIterObject *self, void *NPY_UNUSED(ignored))
1079{
1080 int nd;
1081 nd = PyArray_NDIM(self->ao);
1082 if (self->contiguous) {
1083 /*
1084 * coordinates not kept track of ---
1085 * need to generate from index
1086 */
1087 npy_intp val;
1088 int i;
1089 val = self->index;
1090 for (i = 0; i < nd; i++) {
1091 if (self->factors[i] != 0) {
1092 self->coordinates[i] = val / self->factors[i];
1093 val = val % self->factors[i];
1094 } else {
1095 self->coordinates[i] = 0;
1096 }
1097 }
1098 }
1099 return PyArray_IntTupleFromIntp(nd, self->coordinates);
1100}
1101
1102static PyGetSetDef iter_getsets[] = {
1103 {"index",

Callers

nothing calls this directly

Calls 2

PyArray_NDIMFunction · 0.85
PyArray_IntTupleFromIntpFunction · 0.85

Tested by

no test coverage detected