Skip to main content

A library to simplify and automate einsum operations in a more intuitive way.

Project description

eincraft

eincraft is an experimental Python library designed to simplify and automate einsum operations in a more intuitive and user-friendly way. In its current alpha state, the library allows you to write einsum operations in a more straightforward and readable format, such as C.ik = A.ij * B.jk, rather than using the traditional einsum notation.

Installation

To install eincraft, you can use pip:

pip install .

If you want to enable support for the optional opt_einsum backend, install it with:

pip install .[opt_einsum]

Usage

Here's an example of how to use eincraft:

import numpy as np
import eincraft as ec

# Create tensor objects
A = ec.EinTen('A')
B = ec.EinTen('B')
C = ec.EinTen('C')
Z = ec.EinTen('Z')


# Write einsum operation
Z.kji = 2.0 * A.ij * B.jk * C.ijk + 4.0 * A.ij * 2.0 * B.id * C.idk
Z.ijk += 0.25 * A.ij * B.jk * C.kdd

# Define the numpy arrays
a = np.random.rand(3, 3)
b = np.random.rand(3, 3)
c = np.random.rand(3, 3, 3)

# Evaluate the einsum operations
z = Z.evaluate(A=a, B=b, C=c)

# Let's check the result
np.allclose(z, 2.0 * np.einsum('ij,jk,ijk->kji', a, b, c) + 4.0 * np.einsum('ij,id,idk->ijk', a, 2.0 * b, c) + 0.25 * np.einsum('ij,jk,kdd->ijk', a, b, c))

Running the tests

To run the tests, you can use the following command:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eincraft-0.1.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eincraft-0.1.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file eincraft-0.1.1.tar.gz.

File metadata

  • Download URL: eincraft-0.1.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for eincraft-0.1.1.tar.gz
Algorithm Hash digest
SHA256 49b0035d9af2e8d7f26c294463aa9e44fe75a1d4703c4722e9433036f9a6dfa0
MD5 13f8d0c76674f231ab95c58199f10996
BLAKE2b-256 a88d792ce5f397effb3038484abf5fb72652b0c2b4572ff2ff547215b750cea5

See more details on using hashes here.

File details

Details for the file eincraft-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: eincraft-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for eincraft-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 318cdedf3fcca4696fa5d41b4b5cebcbc2306be1148162169909a18fc6daa6ff
MD5 c2f9b1c023c6fb4a05c14570221053e6
BLAKE2b-256 55983db05fef02a282e1a0a1dc368de73e652b46b3cc267d97abe7327b8a262f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page