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

Function npyiter_init

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

Source from the content-addressed store, hash-verified

686}
687
688static int
689npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds)
690{
691 static char *kwlist[] = {"op", "flags", "op_flags", "op_dtypes",
692 "order", "casting", "op_axes", "itershape",
693 "buffersize",
694 NULL};
695
696 PyObject *op_in = NULL, *op_flags_in = NULL,
697 *op_dtypes_in = NULL, *op_axes_in = NULL;
698
699 int iop, nop = 0;
700 PyArrayObject *op[NPY_MAXARGS];
701 npy_uint32 flags = 0;
702 NPY_ORDER order = NPY_KEEPORDER;
703 NPY_CASTING casting = NPY_SAFE_CASTING;
704 npy_uint32 op_flags[NPY_MAXARGS];
705 PyArray_Descr *op_request_dtypes[NPY_MAXARGS];
706 int oa_ndim = -1;
707 int op_axes_arrays[NPY_MAXARGS][NPY_MAXDIMS];
708 int *op_axes[NPY_MAXARGS];
709 PyArray_Dims itershape = {NULL, -1};
710 int buffersize = 0;
711
712 if (self->iter != NULL) {
713 PyErr_SetString(PyExc_ValueError,
714 "Iterator was already initialized");
715 return -1;
716 }
717
718 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&OOO&O&OO&i:nditer", kwlist,
719 &op_in,
720 NpyIter_GlobalFlagsConverter, &flags,
721 &op_flags_in,
722 &op_dtypes_in,
723 PyArray_OrderConverter, &order,
724 PyArray_CastingConverter, &casting,
725 &op_axes_in,
726 PyArray_OptionalIntpConverter, &itershape,
727 &buffersize)) {
728 npy_free_cache_dim_obj(itershape);
729 return -1;
730 }
731
732 /* Set the dtypes and ops to all NULL to start */
733 memset(op_request_dtypes, 0, sizeof(op_request_dtypes));
734
735 /* op and op_flags */
736 if (npyiter_convert_ops(op_in, op_flags_in, op, op_flags, &nop)
737 != 1) {
738 goto fail;
739 }
740
741 /* op_request_dtypes */
742 if (op_dtypes_in != NULL && op_dtypes_in != Py_None &&
743 npyiter_convert_dtypes(op_dtypes_in,
744 op_request_dtypes, nop) != 1) {
745 goto fail;

Callers

nothing calls this directly

Calls 7

npy_free_cache_dim_objFunction · 0.85
npyiter_convert_opsFunction · 0.85
npyiter_convert_dtypesFunction · 0.85
npyiter_convert_op_axesFunction · 0.85
NpyIter_AdvancedNewFunction · 0.85
npyiter_cache_valuesFunction · 0.85
NpyIter_GetIterSizeFunction · 0.85

Tested by

no test coverage detected