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

Function PyArray_Empty

numpy/core/src/multiarray/ctors.c:2879–2908  ·  view source on GitHub ↗

NUMPY_API * Empty * * accepts NULL type * steals a reference to type */

Source from the content-addressed store, hash-verified

2877 * steals a reference to type
2878 */
2879NPY_NO_EXPORT PyObject *
2880PyArray_Empty(int nd, npy_intp const *dims, PyArray_Descr *type, int is_f_order)
2881{
2882 PyArrayObject *ret;
2883
2884 if (!type) type = PyArray_DescrFromType(NPY_DEFAULT_TYPE);
2885
2886 /*
2887 * PyArray_NewFromDescr steals a ref,
2888 * but we need to look at type later.
2889 * */
2890 ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type,
2891 type, nd, dims,
2892 NULL, NULL,
2893 is_f_order, NULL);
2894 if (ret == NULL) {
2895 return NULL;
2896 }
2897
2898 /* Logic shared by `empty`, `empty_like`, and `ndarray.__new__` */
2899 if (PyDataType_REFCHK(PyArray_DESCR(ret))) {
2900 PyArray_FillObjectArray(ret, Py_None);
2901 if (PyErr_Occurred()) {
2902 Py_DECREF(ret);
2903 return NULL;
2904 }
2905 }
2906
2907 return (PyObject *)ret;
2908}
2909
2910/*
2911 * Like ceil(value), but check for overflow.

Callers 6

array_emptyFunction · 0.85
PyArray_RoundFunction · 0.85
read_rowsFunction · 0.85
execute_real_forwardFunction · 0.85
execute_real_backwardFunction · 0.85

Calls 3

PyArray_NewFromDescrFunction · 0.85
PyArray_DESCRFunction · 0.85
PyArray_FillObjectArrayFunction · 0.85

Tested by

no test coverage detected