Skip to main content

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

Project description

Tensor Network Editor logo

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 edit

This command starts a local server and waits until you press Done or Cancel in the browser session.

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

tensor-network-editor edit --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.3.0.tar.gz (416.9 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.3.0-py3-none-any.whl (497.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tensor_network_editor-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4ae53feaaa5a86f334396946798928c26fad370ea5de400086fe8db5faa990cd
MD5 a8989c94bc17d1498ebbd89dbda2409a
BLAKE2b-256 6a0a946be72461d515f50f1c73e84fa1094631042e9d3cb438c98836be0a8496

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tensor_network_editor-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 439ddc068ee43179a5e7b7e344d8ed455b9210cc38a8a10956fe9c55410ed19a
MD5 80d1123d58515c080f13f30c9d43d563
BLAKE2b-256 e5e32aa01f80b98aa6e4f219db46340635a592b796e4032c37761e2a62af6d29

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