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

Function PyUFunc_AddLoopFromSpec

numpy/core/src/umath/dispatching.c:153–179  ·  view source on GitHub ↗

* Add loop directly to a ufunc from a given ArrayMethod spec. */

Source from the content-addressed store, hash-verified

151 * Add loop directly to a ufunc from a given ArrayMethod spec.
152 */
153NPY_NO_EXPORT int
154PyUFunc_AddLoopFromSpec(PyObject *ufunc, PyArrayMethod_Spec *spec)
155{
156 if (!PyObject_TypeCheck(ufunc, &PyUFunc_Type)) {
157 PyErr_SetString(PyExc_TypeError,
158 "ufunc object passed is not a ufunc!");
159 return -1;
160 }
161 PyBoundArrayMethodObject *bmeth =
162 (PyBoundArrayMethodObject *)PyArrayMethod_FromSpec(spec);
163 if (bmeth == NULL) {
164 return -1;
165 }
166 int nargs = bmeth->method->nin + bmeth->method->nout;
167 PyObject *dtypes = PyArray_TupleFromItems(
168 nargs, (PyObject **)bmeth->dtypes, 1);
169 if (dtypes == NULL) {
170 return -1;
171 }
172 PyObject *info = PyTuple_Pack(2, dtypes, bmeth->method);
173 Py_DECREF(bmeth);
174 Py_DECREF(dtypes);
175 if (info == NULL) {
176 return -1;
177 }
178 return PyUFunc_AddLoop((PyUFuncObject *)ufunc, info, 0);
179}
180
181
182/**

Callers 1

add_loopFunction · 0.85

Calls 3

PyArrayMethod_FromSpecFunction · 0.85
PyArray_TupleFromItemsFunction · 0.85
PyUFunc_AddLoopFunction · 0.85

Tested by

no test coverage detected