numpy.ufunc.signature#

attribute

ufunc.signature#

Definition of the core elements a generalized ufunc operates on.

The signature determines how the dimensions of each input/output arrayare split into core and loop dimensions:

  1. Each dimension in the signature is matched to a dimension of thecorresponding passed-in array, starting from the end of the shape tuple.

  2. Core dimensions assigned to the same label in the signature must haveexactly matching sizes, no broadcasting is performed.

  3. The core dimensions are removed from all inputs and the remainingdimensions are broadcast together, defining the loop dimensions.

Notes

Generalized ufuncs are used internally in many linalg functions, and inthe testing suite; the examples below are taken from these.For ufuncs that operate on scalars, the signature is None, which isequivalent to ‘()’ for every argument.

Examples

>>>importnumpyasnp>>>np.linalg._umath_linalg.det.signature'(m,m)->()'>>>np.matmul.signature'(n?,k),(k,m?)->(n?,m?)'>>>np.add.signatureisNoneTrue  # equivalent to '(),()->()'
On this page