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

Function array_imag_set

numpy/core/src/multiarray/getset.c:816–848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

814}
815
816static int
817array_imag_set(PyArrayObject *self, PyObject *val, void *NPY_UNUSED(ignored))
818{
819 if (val == NULL) {
820 PyErr_SetString(PyExc_AttributeError,
821 "Cannot delete array imaginary part");
822 return -1;
823 }
824 if (PyArray_ISCOMPLEX(self)) {
825 PyArrayObject *ret;
826 PyArrayObject *new;
827 int retcode;
828
829 ret = _get_part(self, 1);
830 if (ret == NULL) {
831 return -1;
832 }
833 new = (PyArrayObject *)PyArray_FROM_O(val);
834 if (new == NULL) {
835 Py_DECREF(ret);
836 return -1;
837 }
838 retcode = PyArray_MoveInto(ret, new);
839 Py_DECREF(ret);
840 Py_DECREF(new);
841 return retcode;
842 }
843 else {
844 PyErr_SetString(PyExc_TypeError,
845 "array does not have imaginary part to set");
846 return -1;
847 }
848}
849
850static PyObject *
851array_flat_get(PyArrayObject *self, void *NPY_UNUSED(ignored))

Callers

nothing calls this directly

Calls 2

_get_partFunction · 0.85
PyArray_MoveIntoFunction · 0.85

Tested by

no test coverage detected