Interactive local editor for building tensor networks and generating Python code.
Project description
Tensor Network Editor
tensor-network-editor is a local, offline-friendly Python package for building tensor networks interactively and generating Python code for a chosen backend.
This 0.1.2 release is aimed at researchers and developers who want a lightweight visual editor that still returns plain Python data structures and code.
Highlights
- Build tensor-network diagrams in a local browser session.
- Save and load versioned JSON designs.
- Generate readable Python code for
tensornetwork,quimb,tensorkrowch,einsum_numpy, andeinsum_torch. - Insert built-in templates for MPS, MPO, PEPS grids, MERA, and binary-tree layouts with corrected open legs.
- Configure template graph size, bond dimension, and physical dimension directly from the editor before insertion.
- Add notes, select them together with tensors and groups, and move mixed selections on the canvas.
- Use the package as a library or from the
tensor-network-editorCLI. - Run on Windows and Linux with Python
3.11+.
Installation
Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -U pip
python -m pip install .
Linux:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
python -m pip install .
Optional extras:
python -m pip install ".[quimb]"
python -m pip install ".[tensornetwork]"
python -m pip install ".[tensorkrowch]"
python -m pip install ".[desktop]"
Quick Start
Python API:
from tensor_network_editor import EngineName, launch_tensor_network_editor
result = launch_tensor_network_editor(default_engine=EngineName.EINSUM_NUMPY)
if result is not None:
print(result.spec.name)
if result.codegen is not None:
print(result.codegen.code)
CLI:
tensor-network-editor --engine einsum_numpy
Load an existing design:
tensor-network-editor --load my_network.json --engine quimb
Template Inserts
The editor includes a small template panel next to the Template selector.
Graph sizechanges meaning by template:MPSandMPO: number of sitesPEPS: side length of the square gridMERAandBinary Tree: depth
Bond dimensionis shared across internal links created by that template.Physical dimensionis shared across all physical legs created by that template.
Default starting values match the built-in presets:
MPS: 4 sitesMPO: 4 sitesPEPS: 2x2MERA: depth 3Binary Tree: depth 3
Public API
launch_tensor_network_editor(...) -> EditorResult | Nonegenerate_code(spec, engine=...) -> CodegenResultsave_spec(spec, path) -> Noneload_spec(path) -> NetworkSpec
The editor blocks until the user presses Done or Cancel. On Done, it returns the abstract NetworkSpec and the generated code for the selected engine.
Supported engine values:
tensornetworkquimbtensorkrowcheinsum_numpyeinsum_torch
Architecture
The package is split into small layers:
models.py: abstract source-of-truth objects likeNetworkSpec,TensorSpec,IndexSpec, andEdgeSpecvalidation.py: checks names, dimensions, endpoints, duplicate connections, and serialization safetyserialization.py: JSON save/load with a versioned wire formatcodegen/: one generator per engine plus a shared normalization layerapp/: local HTTP server, blocking session management, and the offline frontend assets
The frontend uses Cytoscape.js, bundled locally in the package, so the editor does not depend on a CDN or a Node runtime for end users.
Development
Create the virtual environment and install the project in editable mode with the development tools:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -U pip
python -m pip install -e ".[dev]"
Useful checks:
python -m ruff check . --fix
python -m ruff format .
python -m mypy
python -m pyright
python -m pytest
python -m build
python -m twine check dist/*
To remove local caches and generated build artifacts on Windows without touching .venv, run:
.\scripts\clean.bat
On Linux, use:
./scripts/clean.sh
Bundled third-party notices for redistributed frontend assets are tracked in THIRD_PARTY_LICENSES.
Save Format
Designs are stored as plain JSON with a schema wrapper:
{
"schema_version": 3,
"network": {
"...": "..."
}
}
Current Limits
- No hyperedges
- No real tensor data editing: generated tensors are initialized to zeros
- No TenPy backend in
0.1.2 - No desktop wrapper by default
Future Extension Points
The project is already prepared for a future optional pywebview wrapper because the browser launcher is separate from:
EditorSession, which owns validation and return valuesEditorServer, which serves the same app locally
That means a desktop extra can reuse the same UI and backend flow without changing the core model or the generators.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tensor_network_editor-0.1.2.tar.gz.
File metadata
- Download URL: tensor_network_editor-0.1.2.tar.gz
- Upload date:
- Size: 194.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad45f369eb8d08e48692dc5b24216e0998c94365ff6fb78ebdfca0d8db267898
|
|
| MD5 |
df8eb16aee173faff862a68223b7b27b
|
|
| BLAKE2b-256 |
fdcaf831b66671161c17d1866ca9c0c2883dfae7e65877b3d326c0d94ea4628e
|
File details
Details for the file tensor_network_editor-0.1.2-py3-none-any.whl.
File metadata
- Download URL: tensor_network_editor-0.1.2-py3-none-any.whl
- Upload date:
- Size: 211.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b59589199f7ac3f304afc9b987825a48ca836942f5f547e86539c37f871ab506
|
|
| MD5 |
16352736fae54c4e212e2f54ed5fa959
|
|
| BLAKE2b-256 |
269d748abc87788beec44abf5cd3c91602ab241781ad3a72d99b3e4714793d9b
|