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

Function _ufunc_setup_flags

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

* Set per-operand flags according to desired input or output flags. * op_flags[i] for i in input (as determined by ufunc->nin) will be * merged with op_in_flags, perhaps overriding per-operand flags set * in previous stages. * op_flags[i] for i in output will be set to op_out_flags only if previously * unset. * The input flag behavior preserves backward compatibility, while the * output fla

Source from the content-addressed store, hash-verified

382 * output flag behaviour is the "correct" one for maximum flexibility.
383 */
384NPY_NO_EXPORT void
385_ufunc_setup_flags(PyUFuncObject *ufunc, npy_uint32 op_in_flags,
386 npy_uint32 op_out_flags, npy_uint32 *op_flags)
387{
388 int nin = ufunc->nin;
389 int nout = ufunc->nout;
390 int nop = nin + nout, i;
391 /* Set up the flags */
392 for (i = 0; i < nin; ++i) {
393 op_flags[i] = ufunc->op_flags[i] | op_in_flags;
394 /*
395 * If READWRITE flag has been set for this operand,
396 * then clear default READONLY flag
397 */
398 if (op_flags[i] & (NPY_ITER_READWRITE | NPY_ITER_WRITEONLY)) {
399 op_flags[i] &= ~NPY_ITER_READONLY;
400 }
401 }
402 for (i = nin; i < nop; ++i) {
403 op_flags[i] = ufunc->op_flags[i] ? ufunc->op_flags[i] : op_out_flags;
404 }
405}
406
407/*
408 * This function analyzes the input arguments

Calls

no outgoing calls

Tested by

no test coverage detected