NUMPY_API * Generic new array creation routine. */
| 1170 | * Generic new array creation routine. |
| 1171 | */ |
| 1172 | NPY_NO_EXPORT PyObject * |
| 1173 | PyArray_New( |
| 1174 | PyTypeObject *subtype, int nd, npy_intp const *dims, int type_num, |
| 1175 | npy_intp const *strides, void *data, int itemsize, int flags, |
| 1176 | PyObject *obj) |
| 1177 | { |
| 1178 | PyArray_Descr *descr; |
| 1179 | PyObject *new; |
| 1180 | |
| 1181 | if (subtype == NULL) { |
| 1182 | PyErr_SetString(PyExc_ValueError, |
| 1183 | "subtype is NULL in PyArray_New"); |
| 1184 | return NULL; |
| 1185 | } |
| 1186 | |
| 1187 | descr = PyArray_DescrFromType(type_num); |
| 1188 | if (descr == NULL) { |
| 1189 | return NULL; |
| 1190 | } |
| 1191 | if (PyDataType_ISUNSIZED(descr)) { |
| 1192 | if (itemsize < 1) { |
| 1193 | PyErr_SetString(PyExc_ValueError, |
| 1194 | "data type must provide an itemsize"); |
| 1195 | Py_DECREF(descr); |
| 1196 | return NULL; |
| 1197 | } |
| 1198 | PyArray_DESCR_REPLACE(descr); |
| 1199 | if (descr == NULL) { |
| 1200 | return NULL; |
| 1201 | } |
| 1202 | descr->elsize = itemsize; |
| 1203 | } |
| 1204 | new = PyArray_NewFromDescr(subtype, descr, nd, dims, strides, |
| 1205 | data, flags, obj); |
| 1206 | return new; |
| 1207 | } |
| 1208 | |
| 1209 | |
| 1210 | NPY_NO_EXPORT PyArray_Descr * |
no test coverage detected