Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adtzlr/named-einsum
NumPy's Einsum, but with named subscripts.
https://github.com/adtzlr/named-einsum
einsum numpy python
Last synced: about 2 months ago
JSON representation
NumPy's Einsum, but with named subscripts.
- Host: GitHub
- URL: https://github.com/adtzlr/named-einsum
- Owner: adtzlr
- License: mit
- Created: 2023-10-15T21:43:50.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-16T08:24:07.000Z (about 1 year ago)
- Last Synced: 2024-10-12T16:40:58.623Z (3 months ago)
- Topics: einsum, numpy, python
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Neinsum
A Named Einsum.
> *NumPy's Einsum, but with named subscripts.*
[![PyPI version shields.io](https://img.shields.io/pypi/v/neinsum.svg)](https://pypi.python.org/pypi/neinsum/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) [![codecov](https://codecov.io/gh/adtzlr/named-einsum/graph/badge.svg?token=akiKR6sHEb)](https://codecov.io/gh/adtzlr/named-einsum) ![Codestyle black](https://img.shields.io/badge/code%20style-black-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.```python
import numpy as np
from neinsum import named_einsumx = 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)
```