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 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.2.2.tar.gz (283.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.2-py3-none-any.whl (331.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tensor_network_editor-0.2.2.tar.gz
  • Upload date:
  • Size: 283.0 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.2.2.tar.gz
Algorithm Hash digest
SHA256 07a1e2e1cb27d8b3041d636c7d5bf1b92c81444e616423c9671e1b3cf9da0ea7
MD5 ff9579909e4eff03f10986760506d2bf
BLAKE2b-256 7a12742f4820be601cd6770fcea36f665f142fa0d0b34d86276f296c4b34b2bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tensor_network_editor-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf9ccd349add1b51299892a7e6be58c49f86e867fef28e0a50675cc60ff51dbb
MD5 75097f6263066ca5883cc98bc58071ee
BLAKE2b-256 60e8b61bdf6557803a777c4aebb7e13993e006441938a6b55ef38fe706205b07

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