| 1212 | |
| 1213 | |
| 1214 | NPY_NO_EXPORT int |
| 1215 | install_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 |
no test coverage detected