Skip to main content

Minimal Matplotlib visualizations for TensorKrowch tensor networks.

Project description

Tensor-Network-Visualization

Minimal Matplotlib visualizations for TensorKrowch tensor networks.

Repository: https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization

Features

  • 2D and 3D plotting for TensorKrowch tensor networks
  • Tensors rendered as nodes
  • Contractions rendered as edges between tensors
  • Dangling indices rendered as labeled stubs
  • Self-contractions rendered as loops
  • No UI; uses Matplotlib for rendering and NetworkX for graph layouts

Installation

As a dependency

Add to your project's pyproject.toml:

[project]
dependencies = ["tensor-network-visualization>=0.1.0"]

Or install with pip:

pip install tensor-network-visualization

Local development

Inside the project virtual environment:

.\.venv\Scripts\python -m pip install -e ".[dev]"

For runtime-only (editable install without dev tools):

.\.venv\Scripts\python -m pip install -e .

Usage

Input formats

You can pass either:

  • TensorNetwork — object with nodes or leaf_nodes (iterable or dict)
  • List or tuple of nodes — e.g. [node1, node2, ...] for a subset or nodes from different networks

Each node must have edges, axes_names, and name. Each edge must have node1, node2, and name.

When passing a subset of nodes, edges to nodes outside the list are drawn as dangling legs. Disconnected components (e.g. nodes from different networks) are supported.

from tensor_network_viz import PlotConfig, show_tensor_network

config = PlotConfig(figsize=(8, 6))

# From a TensorNetwork
fig, ax = show_tensor_network(network, engine="tensorkrowch", view="2d", config=config)

# From a list of nodes (subset, or nodes without a TensorNetwork)
fig, ax = show_tensor_network([node1, node2, node3], engine="tensorkrowch", view="2d", config=config)

You can also use the TensorKrowch-specific helpers directly:

from tensor_network_viz.tensorkrowch import plot_tensorkrowch_network_2d, plot_tensorkrowch_network_3d

plot_tensorkrowch_network_2d(network)   # or plot_tensorkrowch_network_2d([node1, node2, ...])
plot_tensorkrowch_network_3d(network)

Project layout

  • examples/ — Demo scripts. Run python examples/tensor_network_demo.py mps 2d from the project root. Use --from-list to pass nodes as a list instead of the TensorNetwork.
  • scripts/ — Utility scripts (e.g. clean.py to remove caches and build artifacts).

Development

.\.venv\Scripts\python -m ruff check .
.\.venv\Scripts\python -m pyright
.\.venv\Scripts\python -m pytest

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_visualization-1.1.0.tar.gz (15.6 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_visualization-1.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file tensor_network_visualization-1.1.0.tar.gz.

File metadata

File hashes

Hashes for tensor_network_visualization-1.1.0.tar.gz
Algorithm Hash digest
SHA256 91d844ea2d2c90600a7775c284ec97aa47808e23717c4ecf5168c1d698f15795
MD5 79d5349789a785faa7531b650c8436c8
BLAKE2b-256 e6d4f9585d14d06cd1d299fa66ba071fe57b8d3da21eb466f8e72e2e3a99a7e2

See more details on using hashes here.

File details

Details for the file tensor_network_visualization-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tensor_network_visualization-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c02480de5a45991343b6dc5726c5ec71dc7c076400e759b29cfa22ad899a2c0a
MD5 a86c221077cf2d72539fb17b9aa0277c
BLAKE2b-256 368d27135e619b4e8e048f2b66662cc7e02b28ef473511e0439ad19a8b211988

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