# 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

      >>> np.core.umath_tests.matrix_multiply.signature
      '(m,n),(n,p)->(m,p)'
      >>> np.linalg._umath_linalg.det.signature
      '(m,m)->()'
      >>> np.add.signature is None
      True  # equivalent to '(),()->()'