| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
tensor-network-editor is a local Python package for describing complex tensor networks once, saving them as versioned JSON, and generating readable Python code for several backends.
The main goal is simple multi-framework code generation for tensor networks that would otherwise be tedious to write by hand. The local editor is the modeling surface that makes those networks easier to build and revise, while static figure export is a secondary convenience when you need documentation or paper-ready assets.
It is useful when you want a simple workflow for complex tensor-network code 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.
The editor server runs locally on your own machine. By default it opens in your browser, and you can also ask for a native pywebview window with the optional desktop extra. No Node runtime or cloud service is needed for normal use. The browser-served editor remains the core interface and compatibility target.
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-editorBash:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
python -m pip install tensor-network-editorFor backend extras such as tensor-network-editor[numpy] and tensor-network-editor[torch], automatic planner support, source installs, and development setup, read docs/installation.md.
Launch the visual editor:
tensor-network-editor editThis command starts a local server and waits until you press Done or Cancel in the editor session.
Open the same local editor in a native pywebview window:
python -m pip install "tensor-network-editor[desktop]"
tensor-network-editor edit --ui pywebviewStart only the local server and open the printed URL yourself:
tensor-network-editor edit --ui serverPick a color theme when you launch the editor:
tensor-network-editor edit --theme lightOpen 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.pyGenerate a reproducible benchmark table from one saved design:
tensor-network-editor benchmark my_network.json
tensor-network-editor benchmark my_network.json --dtype float32 --format csv --output benchmark.csvRun a friendly local diagnostic that combines validation, lint, analysis, benchmark, optional-backend checks, and practical suggestions:
tensor-network-editor doctor my_network.json
tensor-network-editor doctor my_network.json --format jsonRender one saved design as SVG, PDF, TikZ/LaTeX, Graphviz/DOT, Mermaid, or PNG:
tensor-network-editor render my_network.json --format svg --output figure.svg
tensor-network-editor render my_network.json --format pdf --output figure.pdf
tensor-network-editor render my_network.json --format tikz --output figure.tex
tensor-network-editor render my_network.json --format dot --output graph.dot
tensor-network-editor render my_network.json --format mermaid --output graph.mmd
tensor-network-editor render my_network.json --format png --output figure.pngThe editor File menu also offers direct academic .svg, .png, .pdf, .tex, and .dot exports for the current canvas.
Use the editor from Python:
from tensor_network_editor import open_editor
from tensor_network_editor.editor import EditorLaunchOptions
def main() -> None:
result = open_editor(options=EditorLaunchOptions(theme="colorblind"))
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()Build a small network directly from Python:
from tensor_network_editor import NetworkBuilder
builder = NetworkBuilder("demo")
a = builder.tensor("A")
a.index("i", 2)
a.index("x", 3)
b = builder.tensor("B")
b.index("x", 3)
b.index("j", 4)
builder.connect(a["x"], b["x"], name="bond_x")
spec = builder.build()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)Render static figures from Python:
from tensor_network_editor import (
load_spec,
render_spec_dot,
render_spec_mermaid,
render_spec_pdf,
render_spec_png,
render_spec_svg,
render_spec_tikz,
)
spec = load_spec("my_network.json")
svg = render_spec_svg(spec, output_path="figure.svg")
tikz = render_spec_tikz(spec, output_path="figure.tex")
dot = render_spec_dot(spec, output_path="graph.dot")
mermaid = render_spec_mermaid(spec, output_path="graph.mmd")
png = render_spec_png(spec, output_path="figure.png")
pdf = render_spec_pdf(spec, output_path="figure.pdf")Load a live quimb or tensornetwork object from Python source:
from tensor_network_editor import PythonLoadOptions, load_python_spec
spec = load_python_spec(
python_source,
python=PythonLoadOptions(
import_mode="live",
object_name="network",
),
)This live mode executes the source in a subprocess with the active Python interpreter from your .venv, auto-detects one supported runtime object when possible, and falls back to python_object_name when several compatible globals exist.
Python imports also expose an explicit reconstruction contract through PythonLoadOptions(reconstruction_level="auto" | "simple" | "best_available"):
When import_mode="live" is requested for generated source but the generated backend package is missing from the active .venv, the loader falls back to the static parser and reports that fallback as a warning instead of failing the whole load immediately.
| Back | FazBrowse Home | New Git URL |