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

Function PyArray_FillObjectArray

numpy/core/src/multiarray/refcount.c:361–398  ·  view source on GitHub ↗

NUMPY_API * Assumes contiguous */

Source from the content-addressed store, hash-verified

359 * Assumes contiguous
360 */
361NPY_NO_EXPORT void
362PyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)
363{
364 PyArray_Descr* descr = PyArray_DESCR(arr);
365
366 // non-legacy dtypes are responsible for initializing
367 // their own internal references
368 if (!NPY_DT_is_legacy(NPY_DTYPE(descr))) {
369 return;
370 }
371
372 npy_intp i,n;
373 n = PyArray_SIZE(arr);
374 if (descr->type_num == NPY_OBJECT) {
375 PyObject **optr;
376 optr = (PyObject **)(PyArray_DATA(arr));
377 n = PyArray_SIZE(arr);
378 if (obj == NULL) {
379 for (i = 0; i < n; i++) {
380 *optr++ = NULL;
381 }
382 }
383 else {
384 for (i = 0; i < n; i++) {
385 Py_INCREF(obj);
386 *optr++ = obj;
387 }
388 }
389 }
390 else {
391 char *optr;
392 optr = PyArray_DATA(arr);
393 for (i = 0; i < n; i++) {
394 _fillobject(optr, obj, descr);
395 optr += descr->elsize;
396 }
397 }
398}
399
400static void
401_fillobject(char *optr, PyObject *obj, PyArray_Descr *dtype)

Callers 3

PyArray_EmptyFunction · 0.85
array_newFunction · 0.85

Calls 3

PyArray_DESCRFunction · 0.85
PyArray_DATAFunction · 0.85
_fillobjectFunction · 0.85

Tested by

no test coverage detected