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

Function install_logical_ufunc_promoter

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

Source from the content-addressed store, hash-verified

1212
1213
1214NPY_NO_EXPORT int
1215install_logical_ufunc_promoter(PyObject *ufunc)
1216{
1217 if (PyObject_Type(ufunc) != (PyObject *)&PyUFunc_Type) {
1218 PyErr_SetString(PyExc_RuntimeError,
1219 "internal numpy array, logical ufunc was not a ufunc?!");
1220 return -1;
1221 }
1222 PyObject *dtype_tuple = PyTuple_Pack(3,
1223 &PyArrayDescr_Type, &PyArrayDescr_Type, &PyArrayDescr_Type, NULL);
1224 if (dtype_tuple == NULL) {
1225 return -1;
1226 }
1227 PyObject *promoter = PyCapsule_New(&logical_ufunc_promoter,
1228 "numpy._ufunc_promoter", NULL);
1229 if (promoter == NULL) {
1230 Py_DECREF(dtype_tuple);
1231 return -1;
1232 }
1233
1234 PyObject *info = PyTuple_Pack(2, dtype_tuple, promoter);
1235 Py_DECREF(dtype_tuple);
1236 Py_DECREF(promoter);
1237 if (info == NULL) {
1238 return -1;
1239 }
1240
1241 return PyUFunc_AddLoop((PyUFuncObject *)ufunc, info, 0);
1242}
1243
1244/*
1245 * Return the PyArrayMethodObject or PyCapsule that matches a registered

Callers 1

initumathFunction · 0.85

Calls 1

PyUFunc_AddLoopFunction · 0.85

Tested by

no test coverage detected