NUMPY_API * Empty * * accepts NULL type * steals a reference to type */
| 2877 | * steals a reference to type |
| 2878 | */ |
| 2879 | NPY_NO_EXPORT PyObject * |
| 2880 | PyArray_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. |
no test coverage detected