Skip to main content

Interactive local editor for building tensor networks and generating Python code.

Project description

Tensor Network Editor

CI Python 3.11+ Windows%20%7C%20Linux MIT License

tensor-network-editor is a local Python package for drawing tensor networks, saving them as versioned JSON, and generating readable Python code for several backends.

It is useful when you want a visual editor without losing the things that make scientific Python workflows practical: plain data objects, files you can version, offline use, and generated code you can inspect.

Why This Project

  • Draw tensor-network diagrams in a local browser session.
  • Save and reload backend-independent JSON designs.
  • Generate code for tensornetwork, quimb, tensorkrowch, einsum_numpy, and einsum_torch.
  • Use built-in templates for MPS, MPO, PEPS, MERA, and binary-tree layouts.
  • Build repeated chains with For mode and export them with any bundled backend.
  • Inspect manual contraction paths and optional planner suggestions.
  • Get structural analysis with FLOP and MAC cost summaries.
  • Use the package from the CLI or directly from Python.

The editor opens in your browser, but the server runs locally on your own machine. No Node runtime or cloud service is needed for normal use.

Minimal Installation

The PyPI package name is tensor-network-editor. The Python import package is tensor_network_editor.

PowerShell:

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -U pip
python -m pip install tensor-network-editor

Bash:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
python -m pip install tensor-network-editor

For backend extras, planner support, source installs, and development setup, read docs/installation.md.

Basic Use

Launch the visual editor:

tensor-network-editor

Open an existing design and save generated code when the session is confirmed:

tensor-network-editor --load my_network.json --engine quimb --save-code generated_network.py

Use the editor from Python:

from tensor_network_editor import launch_tensor_network_editor


def main() -> None:
    result = launch_tensor_network_editor()
    if result is None:
        print("Editor cancelled.")
        return

    print(f"Design name: {result.spec.name}")
    if result.codegen is not None:
        print(result.codegen.code)


if __name__ == "__main__":
    main()

Generate code without opening the editor:

from tensor_network_editor import EngineName, generate_code, load_spec


spec = load_spec("my_network.json")
result = generate_code(spec, engine=EngineName.EINSUM_NUMPY)
print(result.code)

Documentation

Current Limits

  • Hyperedges are not supported yet.
  • Real tensor values are not edited in the visual editor; generated tensors are initialized by the generated backend code.
  • TenPy code generation is not included.
  • For mode works with all bundled backends. Manual outer-product steps still cannot be exported safely to tensorkrowch.

Project Links

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

tensor_network_editor-0.2.1.tar.gz (278.0 kB view details)

Uploaded Source

Built Distribution

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

tensor_network_editor-0.2.1-py3-none-any.whl (312.4 kB view details)

Uploaded Python 3

File details

Details for the file tensor_network_editor-0.2.1.tar.gz.

File metadata

  • Download URL: tensor_network_editor-0.2.1.tar.gz
  • Upload date:
  • Size: 278.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for tensor_network_editor-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2df4c03956f8d4775f004ebbad7a795ea73994e8fd7e508436ca700349e4f39e
MD5 63f56862e590c870cabc104f6c1d26ed
BLAKE2b-256 3f95e26f297e27b6bfeb2b1228351b019161c5225b905a885a830b1e041ab84e

See more details on using hashes here.

File details

Details for the file tensor_network_editor-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tensor_network_editor-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25b2f85c8a1bc3c338c522e05d11d367b2ad455466ffa2b5cf420832cd8f8272
MD5 2ee74485550107f33f4a614aaf20151c
BLAKE2b-256 41964f6a5f641690fbf0a6e623b742acd386ba73a1c8a093264885127266aab2

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