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

Function PyArray_GetPriority

numpy/core/src/multiarray/multiarraymodule.c:133–163  ·  view source on GitHub ↗

NUMPY_API * Get Priority from object */

Source from the content-addressed store, hash-verified

131 * Get Priority from object
132 */
133NPY_NO_EXPORT double
134PyArray_GetPriority(PyObject *obj, double default_)
135{
136 PyObject *ret;
137 double priority = NPY_PRIORITY;
138
139 if (PyArray_CheckExact(obj)) {
140 return priority;
141 }
142 else if (PyArray_CheckAnyScalarExact(obj)) {
143 return NPY_SCALAR_PRIORITY;
144 }
145
146 ret = PyArray_LookupSpecial_OnInstance(obj, npy_ma_str_array_priority);
147 if (ret == NULL) {
148 if (PyErr_Occurred()) {
149 /* TODO[gh-14801]: propagate crashes during attribute access? */
150 PyErr_Clear();
151 }
152 return default_;
153 }
154
155 priority = PyFloat_AsDouble(ret);
156 Py_DECREF(ret);
157 if (error_converting(priority)) {
158 /* TODO[gh-14801]: propagate crashes for bad priority? */
159 PyErr_Clear();
160 return default_;
161 }
162 return priority;
163}
164
165/*NUMPY_API
166 * Multiply a List of ints

Callers 5

new_array_for_sumFunction · 0.85
PyArray_GetSubTypeFunction · 0.85
_find_array_methodFunction · 0.85
binop_should_deferFunction · 0.85

Tested by

no test coverage detected