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

Function iter_ass_subscript

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

Source from the content-addressed store, hash-verified

780}
781
782NPY_NO_EXPORT int
783iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)
784{
785 PyArrayObject *arrval = NULL;
786 PyArrayIterObject *val_it = NULL;
787 PyArray_Descr *type;
788 PyArray_Descr *indtype = NULL;
789 int swap, retval = -1;
790 npy_intp start, step_size;
791 npy_intp n_steps;
792 PyObject *obj = NULL;
793 PyArray_CopySwapFunc *copyswap;
794
795
796 if (val == NULL) {
797 PyErr_SetString(PyExc_TypeError,
798 "Cannot delete iterator elements");
799 return -1;
800 }
801
802 if (PyArray_FailUnlessWriteable(self->ao, "underlying array") < 0)
803 return -1;
804
805 if (ind == Py_Ellipsis) {
806 ind = PySlice_New(NULL, NULL, NULL);
807 retval = iter_ass_subscript(self, ind, val);
808 Py_DECREF(ind);
809 return retval;
810 }
811
812 if (PyTuple_Check(ind)) {
813 int len;
814 len = PyTuple_GET_SIZE(ind);
815 if (len > 1) {
816 goto finish;
817 }
818 ind = PyTuple_GET_ITEM(ind, 0);
819 }
820
821 type = PyArray_DESCR(self->ao);
822
823 /*
824 * Check for Boolean -- this is first because
825 * Bool is a subclass of Int
826 */
827 if (PyBool_Check(ind)) {
828 retval = 0;
829 if (PyObject_IsTrue(ind)) {
830 retval = PyArray_Pack(
831 PyArray_DESCR(self->ao), self->dataptr, val);
832 }
833 goto finish;
834 }
835
836 if (PySequence_Check(ind) || PySlice_Check(ind)) {
837 goto skip;
838 }
839 start = PyArray_PyIntAsIntp(ind);

Callers

nothing calls this directly

Calls 13

PyArray_DESCRFunction · 0.85
PyArray_PackFunction · 0.85
PyArray_PyIntAsIntpFunction · 0.85
check_and_adjust_indexFunction · 0.85
PyArray_FromAnyFunction · 0.85
PyArray_IterNewFunction · 0.85
parse_index_entryFunction · 0.85
PyArray_DATAFunction · 0.85
PyArray_TYPEFunction · 0.85
iter_ass_sub_BoolFunction · 0.85
PyArray_CheckFromAnyFunction · 0.85

Tested by

no test coverage detected