Skip to content

adtzlr/named-einsum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neinsum

A Named Einsum.

NumPy's Einsum, but with named subscripts.

PyPI version shields.io License: MIT codecov Codestyle black

Installation

Neinsum is available on PyPI (and requires NumPy).

pip install neinsum

Usage

With neinsum, it is possible to add names to the subscripts, i.e. instead of the indices-only ij in np.einsum, a named-subscript A_ij has to be provided. The variable names - like A (without indices) - are further used as keyword-arguments, see the example code-block. This is also supported for the output array.

import numpy as np
from neinsum import named_einsum

x = np.eye(3)
y = np.arange(9).reshape(3, 3)

named_einsum("A_ij,B_kl")(A=x, B=y)

# this is equal to
np.einsum("ij,kl", x, y)