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

Function PyArray_New

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

NUMPY_API * Generic new array creation routine. */

Source from the content-addressed store, hash-verified

1170 * Generic new array creation routine.
1171 */
1172NPY_NO_EXPORT PyObject *
1173PyArray_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
1210NPY_NO_EXPORT PyArray_Descr *

Callers 3

PyArray_ArangeFunction · 0.85
new_array_for_sumFunction · 0.85
fortran_getattrFunction · 0.85

Calls 1

PyArray_NewFromDescrFunction · 0.85

Tested by

no test coverage detected