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.


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.


>>> np.linalg._umath_linalg.det.signature
>>> np.matmul.signature
>>> np.add.signature is None
True  # equivalent to '(),()->()'