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

Function NpyIter_NestedIters

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

Source from the content-addressed store, hash-verified

815}
816
817NPY_NO_EXPORT PyObject *
818NpyIter_NestedIters(PyObject *NPY_UNUSED(self),
819 PyObject *args, PyObject *kwds)
820{
821 static char *kwlist[] = {"op", "axes", "flags", "op_flags",
822 "op_dtypes", "order",
823 "casting", "buffersize",
824 NULL};
825
826 PyObject *op_in = NULL, *axes_in = NULL,
827 *op_flags_in = NULL, *op_dtypes_in = NULL;
828
829 int iop, nop = 0, inest, nnest = 0;
830 PyArrayObject *op[NPY_MAXARGS];
831 npy_uint32 flags = 0, flags_inner;
832 NPY_ORDER order = NPY_KEEPORDER;
833 NPY_CASTING casting = NPY_SAFE_CASTING;
834 npy_uint32 op_flags[NPY_MAXARGS], op_flags_inner[NPY_MAXARGS];
835 PyArray_Descr *op_request_dtypes[NPY_MAXARGS],
836 *op_request_dtypes_inner[NPY_MAXARGS];
837 int op_axes_data[NPY_MAXDIMS];
838 int *nested_op_axes[NPY_MAXDIMS];
839 int nested_naxes[NPY_MAXDIMS], iaxes, naxes;
840 int negones[NPY_MAXDIMS];
841 char used_axes[NPY_MAXDIMS];
842 int buffersize = 0;
843
844 PyObject *ret = NULL;
845
846 if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|O&OOO&O&i", kwlist,
847 &op_in,
848 &axes_in,
849 NpyIter_GlobalFlagsConverter, &flags,
850 &op_flags_in,
851 &op_dtypes_in,
852 PyArray_OrderConverter, &order,
853 PyArray_CastingConverter, &casting,
854 &buffersize)) {
855 return NULL;
856 }
857
858 /* axes */
859 if (!PyTuple_Check(axes_in) && !PyList_Check(axes_in)) {
860 PyErr_SetString(PyExc_ValueError,
861 "axes must be a tuple of axis arrays");
862 return NULL;
863 }
864 nnest = PySequence_Size(axes_in);
865 if (nnest < 2) {
866 PyErr_SetString(PyExc_ValueError,
867 "axes must have at least 2 entries for nested iteration");
868 return NULL;
869 }
870 naxes = 0;
871 memset(used_axes, 0, NPY_MAXDIMS);
872 for (inest = 0; inest < nnest; ++inest) {
873 PyObject *item = PySequence_GetItem(axes_in, inest);
874 npy_intp i;

Callers

nothing calls this directly

Calls 8

npyiter_convert_opsFunction · 0.85
npyiter_convert_dtypesFunction · 0.85
npyiter_newFunction · 0.85
NpyIter_AdvancedNewFunction · 0.85
npyiter_cache_valuesFunction · 0.85
NpyIter_GetIterSizeFunction · 0.85
NpyIter_GetOperandArrayFunction · 0.85

Tested by

no test coverage detected