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

Function _find_array_prepare

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

* This function analyzes the input arguments * and determines an appropriate __array_prepare__ function to call * for the outputs. * * If an output argument is provided, then it is prepped * with its own __array_prepare__ not with the one determined by * the input arguments. * * if the provided output argument is already an ndarray, * the prepping function is None (which means no prepping

Source from the content-addressed store, hash-verified

292 * should just have PyArray_Return called.
293 */
294static void
295_find_array_prepare(ufunc_full_args args,
296 PyObject **output_prep, int nout)
297{
298 int i;
299 PyObject *prep;
300
301 /*
302 * Determine the prepping function given by the input arrays
303 * (could be NULL).
304 */
305 prep = _find_array_method(args.in, npy_um_str_array_prepare);
306 /*
307 * For all the output arrays decide what to do.
308 *
309 * 1) Use the prep function determined from the input arrays
310 * This is the default if the output array is not
311 * passed in.
312 *
313 * 2) Use the __array_prepare__ method of the output object.
314 * This is special cased for
315 * exact ndarray so that no PyArray_Return is
316 * done in that case.
317 */
318 if (args.out == NULL) {
319 for (i = 0; i < nout; i++) {
320 Py_XINCREF(prep);
321 output_prep[i] = prep;
322 }
323 }
324 else {
325 for (i = 0; i < nout; i++) {
326 output_prep[i] = _get_output_array_method(
327 PyTuple_GET_ITEM(args.out, i), npy_um_str_array_prepare, prep);
328 }
329 }
330 Py_XDECREF(prep);
331 return;
332}
333
334#define NPY_UFUNC_DEFAULT_INPUT_FLAGS \
335 NPY_ITER_READONLY | \

Callers 1

ufunc_generic_fastcallFunction · 0.85

Calls 2

_find_array_methodFunction · 0.85
_get_output_array_methodFunction · 0.85

Tested by

no test coverage detected