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

Function _get_output_array_method

numpy/core/src/umath/ufunc_object.c:246–276  ·  view source on GitHub ↗

* Returns an incref'ed pointer to the proper __array_prepare__/__array_wrap__ * method for a ufunc output argument, given the output argument `obj`, and the * method chosen from the inputs `input_method`. */

Source from the content-addressed store, hash-verified

244 * method chosen from the inputs `input_method`.
245 */
246static PyObject *
247_get_output_array_method(PyObject *obj, PyObject *method,
248 PyObject *input_method) {
249 if (obj != Py_None) {
250 PyObject *ometh;
251
252 if (PyArray_CheckExact(obj)) {
253 /*
254 * No need to wrap regular arrays - None signals to not call
255 * wrap/prepare at all
256 */
257 Py_RETURN_NONE;
258 }
259
260 ometh = PyObject_GetAttr(obj, method);
261 if (ometh == NULL) {
262 PyErr_Clear();
263 }
264 else if (!PyCallable_Check(ometh)) {
265 Py_DECREF(ometh);
266 }
267 else {
268 /* Use the wrap/prepare method of the output if it's callable */
269 return ometh;
270 }
271 }
272
273 /* Fall back on the input's wrap/prepare */
274 Py_XINCREF(input_method);
275 return input_method;
276}
277
278/*
279 * This function analyzes the input arguments

Callers 2

_find_array_prepareFunction · 0.85
_find_array_wrapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected