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

Function _is_default_descr

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

* Checks if the object in descr is the default 'descr' member for the * __array_interface__ dictionary with 'typestr' member typestr. */

Source from the content-addressed store, hash-verified

2086 * __array_interface__ dictionary with 'typestr' member typestr.
2087 */
2088NPY_NO_EXPORT int
2089_is_default_descr(PyObject *descr, PyObject *typestr) {
2090 if (!PyList_Check(descr) || PyList_GET_SIZE(descr) != 1) {
2091 return 0;
2092 }
2093 PyObject *tuple = PyList_GET_ITEM(descr, 0);
2094 if (!(PyTuple_Check(tuple) && PyTuple_GET_SIZE(tuple) == 2)) {
2095 return 0;
2096 }
2097 PyObject *name = PyTuple_GET_ITEM(tuple, 0);
2098 if (!(PyUnicode_Check(name) && PyUnicode_GetLength(name) == 0)) {
2099 return 0;
2100 }
2101 PyObject *typestr2 = PyTuple_GET_ITEM(tuple, 1);
2102 return PyObject_RichCompareBool(typestr, typestr2, Py_EQ);
2103}
2104
2105
2106/*NUMPY_API*/

Callers 1

PyArray_FromInterfaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected