* 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`. */
| 244 | * method chosen from the inputs `input_method`. |
| 245 | */ |
| 246 | static 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 |
no outgoing calls
no test coverage detected