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

Function PyArray_SetField

numpy/core/src/multiarray/methods.c:467–500  ·  view source on GitHub ↗

NUMPY_API Set a subset of bytes from each element of the array steals reference to dtype, must not be NULL */

Source from the content-addressed store, hash-verified

465 steals reference to dtype, must not be NULL
466*/
467NPY_NO_EXPORT int
468PyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype,
469 int offset, PyObject *val)
470{
471 PyObject *ret = NULL;
472 int retval = 0;
473
474 if (self == NULL) {
475 PyErr_SetString(PyExc_ValueError,
476 "self is NULL in PyArray_SetField");
477 return -1;
478 }
479
480 if (dtype == NULL) {
481 PyErr_SetString(PyExc_ValueError,
482 "dtype is NULL in PyArray_SetField");
483 return -1;
484 }
485
486 if (PyArray_FailUnlessWriteable(self, "assignment destination") < 0) {
487 Py_DECREF(dtype);
488 return -1;
489 }
490
491 /* getfield returns a view we can write to */
492 ret = PyArray_GetField(self, dtype, offset);
493 if (ret == NULL) {
494 return -1;
495 }
496
497 retval = PyArray_CopyObject((PyArrayObject *)ret, val);
498 Py_DECREF(ret);
499 return retval;
500}
501
502static PyObject *
503array_setfield(PyArrayObject *self, PyObject *args, PyObject *kwds)

Callers 1

array_setfieldFunction · 0.85

Calls 3

PyArray_GetFieldFunction · 0.85
PyArray_CopyObjectFunction · 0.85

Tested by

no test coverage detected