Skip to main content
`Ctrl`+`K`

# 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 array are split into core and loop dimensions:

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

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

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

  Notes

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

  Examples

      >>> import numpy as np
      >>> np.linalg._umath_linalg.det.signature
      '(m,m)->()'
      >>> np.matmul.signature
      '(n?,k),(k,m?)->(n?,m?)'
      >>> np.add.signature is None
      True  # equivalent to '(),()->()'