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

Function iter_ass_sub_Bool

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

Source from the content-addressed store, hash-verified

697
698
699static int
700iter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,
701 PyArrayIterObject *val, int swap)
702{
703 npy_intp counter, strides;
704 char *dptr;
705 PyArray_CopySwapFunc *copyswap;
706
707 if (PyArray_NDIM(ind) != 1) {
708 PyErr_SetString(PyExc_ValueError,
709 "boolean index array should have 1 dimension");
710 return -1;
711 }
712
713 counter = PyArray_DIMS(ind)[0];
714 if (counter > self->size) {
715 PyErr_SetString(PyExc_ValueError,
716 "boolean index array has too many values");
717 return -1;
718 }
719
720 strides = PyArray_STRIDES(ind)[0];
721 dptr = PyArray_DATA(ind);
722 PyArray_ITER_RESET(self);
723 /* Loop over Boolean array */
724 copyswap = PyArray_DESCR(self->ao)->f->copyswap;
725 while (counter--) {
726 if (*((npy_bool *)dptr) != 0) {
727 copyswap(self->dataptr, val->dataptr, swap, self->ao);
728 PyArray_ITER_NEXT(val);
729 if (val->index == val->size) {
730 PyArray_ITER_RESET(val);
731 }
732 }
733 dptr += strides;
734 PyArray_ITER_NEXT(self);
735 }
736 PyArray_ITER_RESET(self);
737 return 0;
738}
739
740static int
741iter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,

Callers 1

iter_ass_subscriptFunction · 0.85

Calls 5

PyArray_NDIMFunction · 0.85
PyArray_DIMSFunction · 0.85
PyArray_STRIDESFunction · 0.85
PyArray_DATAFunction · 0.85
PyArray_DESCRFunction · 0.85

Tested by

no test coverage detected