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

Function _find_array_wrap

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

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

Source from the content-addressed store, hash-verified

421 * should just have PyArray_Return called.
422 */
423static void
424_find_array_wrap(ufunc_full_args args, npy_bool subok,
425 PyObject **output_wrap, int nin, int nout)
426{
427 int i;
428 PyObject *wrap = NULL;
429
430 /*
431 * If a 'subok' parameter is passed and isn't True, don't wrap but put None
432 * into slots with out arguments which means return the out argument
433 */
434 if (!subok) {
435 goto handle_out;
436 }
437
438 /*
439 * Determine the wrapping function given by the input arrays
440 * (could be NULL).
441 */
442 wrap = _find_array_method(args.in, npy_um_str_array_wrap);
443
444 /*
445 * For all the output arrays decide what to do.
446 *
447 * 1) Use the wrap function determined from the input arrays
448 * This is the default if the output array is not
449 * passed in.
450 *
451 * 2) Use the __array_wrap__ method of the output object
452 * passed in. -- this is special cased for
453 * exact ndarray so that no PyArray_Return is
454 * done in that case.
455 */
456handle_out:
457 if (args.out == NULL) {
458 for (i = 0; i < nout; i++) {
459 Py_XINCREF(wrap);
460 output_wrap[i] = wrap;
461 }
462 }
463 else {
464 for (i = 0; i < nout; i++) {
465 output_wrap[i] = _get_output_array_method(
466 PyTuple_GET_ITEM(args.out, i), npy_um_str_array_wrap, wrap);
467 }
468 }
469
470 Py_XDECREF(wrap);
471}
472
473
474/*

Calls 2

_find_array_methodFunction · 0.85
_get_output_array_methodFunction · 0.85

Tested by

no test coverage detected