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

Function PyArray_DescrFromObject

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

NUMPY_API * new reference -- accepts NULL for mintype */

Source from the content-addressed store, hash-verified

2465* new reference -- accepts NULL for mintype
2466*/
2467NPY_NO_EXPORT PyArray_Descr *
2468PyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)
2469{
2470 PyArray_Descr *dtype;
2471
2472 dtype = mintype;
2473 Py_XINCREF(dtype);
2474
2475 if (PyArray_DTypeFromObject(op, NPY_MAXDIMS, &dtype) < 0) {
2476 return NULL;
2477 }
2478
2479 if (dtype == NULL) {
2480 return PyArray_DescrFromType(NPY_DEFAULT_TYPE);
2481 }
2482 else {
2483 return dtype;
2484 }
2485}
2486
2487/* These are also old calls (should use PyArray_NewFromDescr) */
2488

Callers 3

PyArray_ArangeObjFunction · 0.85
PyArray_SearchSortedFunction · 0.85
PyArray_ClipFunction · 0.85

Calls 1

PyArray_DTypeFromObjectFunction · 0.85

Tested by

no test coverage detected