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

Function npyiter_remove_axis

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

Source from the content-addressed store, hash-verified

1286}
1287
1288static PyObject *
1289npyiter_remove_axis(NewNpyArrayIterObject *self, PyObject *args)
1290{
1291 int axis = 0;
1292
1293 if (self->iter == NULL) {
1294 PyErr_SetString(PyExc_ValueError,
1295 "Iterator is invalid");
1296 return NULL;
1297 }
1298
1299 if (!PyArg_ParseTuple(args, "i:remove_axis", &axis)) {
1300 return NULL;
1301 }
1302
1303 if (NpyIter_RemoveAxis(self->iter, axis) != NPY_SUCCEED) {
1304 return NULL;
1305 }
1306 /* RemoveAxis invalidates cached values */
1307 if (npyiter_cache_values(self) < 0) {
1308 return NULL;
1309 }
1310 /* RemoveAxis also resets the iterator */
1311 if (NpyIter_GetIterSize(self->iter) == 0) {
1312 self->started = 1;
1313 self->finished = 1;
1314 }
1315 else {
1316 self->started = 0;
1317 self->finished = 0;
1318 }
1319
1320 Py_RETURN_NONE;
1321}
1322
1323static PyObject *
1324npyiter_remove_multi_index(

Callers

nothing calls this directly

Calls 3

NpyIter_RemoveAxisFunction · 0.85
npyiter_cache_valuesFunction · 0.85
NpyIter_GetIterSizeFunction · 0.85

Tested by

no test coverage detected