einx.matches

Contents

einx.matches#

einx.matches(description, *tensors, **parameters)[source]#

Returns whether the given tensors match the einx expression description under the given constraints.

Parameters:
  • description (str) – Comma-separated list of tensor expressions in einx notation.

  • *tensors (Tensor) – Tensors matching the description string. Accepts None for unknown shapes.

  • **parameters (Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes]]) – Additional parameters that specify dimension sizes, e.g. a=4.

Return type:

bool

Returns:

True if the tensors and constraints match the description, False otherwise.

Example

>>> x = np.random.rand(3, 4)
>>> einx.matches("a b", x)
True
>>> einx.matches("a b c", x)
False