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

Function npyiter_value_get

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

Source from the content-addressed store, hash-verified

1389npyiter_seq_item(NewNpyArrayIterObject *self, Py_ssize_t i);
1390
1391static PyObject *
1392npyiter_value_get(NewNpyArrayIterObject *self, void *NPY_UNUSED(ignored))
1393{
1394 PyObject *ret;
1395
1396 npy_intp iop, nop;
1397
1398 if (self->iter == NULL || self->finished) {
1399 PyErr_SetString(PyExc_ValueError,
1400 "Iterator is past the end");
1401 return NULL;
1402 }
1403
1404 nop = NpyIter_GetNOp(self->iter);
1405
1406 /* Return an array or tuple of arrays with the values */
1407 if (nop == 1) {
1408 ret = npyiter_seq_item(self, 0);
1409 }
1410 else {
1411 ret = PyTuple_New(nop);
1412 if (ret == NULL) {
1413 return NULL;
1414 }
1415 for (iop = 0; iop < nop; ++iop) {
1416 PyObject *a = npyiter_seq_item(self, iop);
1417 if (a == NULL) {
1418 Py_DECREF(ret);
1419 return NULL;
1420 }
1421 PyTuple_SET_ITEM(ret, iop, a);
1422 }
1423 }
1424
1425 return ret;
1426}
1427
1428static PyObject *
1429npyiter_operands_get(NewNpyArrayIterObject *self, void *NPY_UNUSED(ignored))

Callers 1

npyiter_nextFunction · 0.85

Calls 2

NpyIter_GetNOpFunction · 0.85
npyiter_seq_itemFunction · 0.85

Tested by

no test coverage detected