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

Function iter_ass_sub_int

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

Source from the content-addressed store, hash-verified

738}
739
740static int
741iter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,
742 PyArrayIterObject *val, int swap)
743{
744 npy_intp num;
745 PyArrayIterObject *ind_it;
746 npy_intp counter;
747 PyArray_CopySwapFunc *copyswap;
748
749 copyswap = PyArray_DESCR(self->ao)->f->copyswap;
750 if (PyArray_NDIM(ind) == 0) {
751 num = *((npy_intp *)PyArray_DATA(ind));
752 if (check_and_adjust_index(&num, self->size, -1, NULL) < 0) {
753 return -1;
754 }
755 PyArray_ITER_GOTO1D(self, num);
756 copyswap(self->dataptr, val->dataptr, swap, self->ao);
757 return 0;
758 }
759 ind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);
760 if (ind_it == NULL) {
761 return -1;
762 }
763 counter = ind_it->size;
764 while (counter--) {
765 num = *((npy_intp *)(ind_it->dataptr));
766 if (check_and_adjust_index(&num, self->size, -1, NULL) < 0) {
767 Py_DECREF(ind_it);
768 return -1;
769 }
770 PyArray_ITER_GOTO1D(self, num);
771 copyswap(self->dataptr, val->dataptr, swap, self->ao);
772 PyArray_ITER_NEXT(ind_it);
773 PyArray_ITER_NEXT(val);
774 if (val->index == val->size) {
775 PyArray_ITER_RESET(val);
776 }
777 }
778 Py_DECREF(ind_it);
779 return 0;
780}
781
782NPY_NO_EXPORT int
783iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)

Callers 1

iter_ass_subscriptFunction · 0.85

Calls 5

PyArray_DESCRFunction · 0.85
PyArray_NDIMFunction · 0.85
PyArray_DATAFunction · 0.85
check_and_adjust_indexFunction · 0.85
PyArray_IterNewFunction · 0.85

Tested by

no test coverage detected