tensor-network-visualization 1.1.0__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tensor_network_visualization-1.3.0/PKG-INFO +213 -0
- tensor_network_visualization-1.3.0/README.md +176 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/pyproject.toml +54 -50
- tensor_network_visualization-1.3.0/src/tensor_network_visualization.egg-info/PKG-INFO +213 -0
- tensor_network_visualization-1.3.0/src/tensor_network_visualization.egg-info/SOURCES.txt +51 -0
- tensor_network_visualization-1.3.0/src/tensor_network_visualization.egg-info/requires.txt +26 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/__init__.py +19 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/__init__.py +1 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/_draw_common.py +356 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/_nodes_edges_common.py +156 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/axis_directions.py +40 -0
- {tensor_network_visualization-1.1.0/src/tensor_network_viz/tensorkrowch → tensor_network_visualization-1.3.0/src/tensor_network_viz/_core}/curves.py +6 -15
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/draw_2d.py +64 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/draw_3d.py +64 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/graph.py +52 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/graph_utils.py +99 -0
- {tensor_network_visualization-1.1.0/src/tensor_network_viz/tensorkrowch → tensor_network_visualization-1.3.0/src/tensor_network_viz/_core}/layout.py +377 -352
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_core/renderer.py +268 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/_registry.py +45 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/src/tensor_network_viz/config.py +63 -60
- tensor_network_visualization-1.3.0/src/tensor_network_viz/einsum_module/__init__.py +10 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/einsum_module/graph.py +190 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/einsum_module/renderer.py +17 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/einsum_module/trace.py +454 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/quimb/__init__.py +9 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/quimb/graph.py +152 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/quimb/renderer.py +17 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/tenpy/__init__.py +9 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/tenpy/graph.py +176 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/tenpy/renderer.py +17 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/tensorkrowch/graph.py +20 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/tensorkrowch/renderer.py +17 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/tensornetwork/__init__.py +9 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/tensornetwork/graph.py +20 -0
- tensor_network_visualization-1.3.0/src/tensor_network_viz/tensornetwork/renderer.py +17 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/src/tensor_network_viz/viewer.py +68 -57
- tensor_network_visualization-1.3.0/tests/test_einsum_autotrace.py +181 -0
- tensor_network_visualization-1.3.0/tests/test_einsum_backend.py +144 -0
- tensor_network_visualization-1.3.0/tests/test_examples.py +276 -0
- tensor_network_visualization-1.3.0/tests/test_integration_einsum.py +75 -0
- tensor_network_visualization-1.3.0/tests/test_integration_quimb.py +39 -0
- tensor_network_visualization-1.3.0/tests/test_integration_tenpy.py +55 -0
- tensor_network_visualization-1.3.0/tests/test_integration_tensornetwork.py +26 -0
- tensor_network_visualization-1.3.0/tests/test_plotting.py +489 -0
- tensor_network_visualization-1.3.0/tests/test_quimb_backend.py +123 -0
- tensor_network_visualization-1.3.0/tests/test_tenpy_backend.py +136 -0
- tensor_network_visualization-1.1.0/PKG-INFO +0 -116
- tensor_network_visualization-1.1.0/README.md +0 -92
- tensor_network_visualization-1.1.0/src/tensor_network_visualization.egg-info/PKG-INFO +0 -116
- tensor_network_visualization-1.1.0/src/tensor_network_visualization.egg-info/SOURCES.txt +0 -22
- tensor_network_visualization-1.1.0/src/tensor_network_visualization.egg-info/requires.txt +0 -8
- tensor_network_visualization-1.1.0/src/tensor_network_viz/__init__.py +0 -10
- tensor_network_visualization-1.1.0/src/tensor_network_viz/tensorkrowch/_draw_common.py +0 -62
- tensor_network_visualization-1.1.0/src/tensor_network_viz/tensorkrowch/draw_2d.py +0 -178
- tensor_network_visualization-1.1.0/src/tensor_network_viz/tensorkrowch/draw_3d.py +0 -202
- tensor_network_visualization-1.1.0/src/tensor_network_viz/tensorkrowch/graph.py +0 -194
- tensor_network_visualization-1.1.0/src/tensor_network_viz/tensorkrowch/renderer.py +0 -181
- tensor_network_visualization-1.1.0/tests/test_plotting.py +0 -198
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/LICENSE +0 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/setup.cfg +0 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/src/tensor_network_visualization.egg-info/dependency_links.txt +0 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/src/tensor_network_visualization.egg-info/top_level.txt +0 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/src/tensor_network_viz/py.typed +0 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/src/tensor_network_viz/tensorkrowch/__init__.py +0 -0
- {tensor_network_visualization-1.1.0 → tensor_network_visualization-1.3.0}/tests/test_integration_tensorkrowch.py +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tensor-network-visualization
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, and TeNPy tensor networks.
|
|
5
|
+
Author: Alejandro Mata Ali
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization
|
|
8
|
+
Keywords: tensor-network,visualization,tensorkrowch,tensornetwork,quimb,tenpy,matplotlib
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: matplotlib>=3.7
|
|
17
|
+
Requires-Dist: networkx>=3.0
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest; extra == "dev"
|
|
20
|
+
Requires-Dist: ruff; extra == "dev"
|
|
21
|
+
Requires-Dist: pyright; extra == "dev"
|
|
22
|
+
Requires-Dist: tensorkrowch; extra == "dev"
|
|
23
|
+
Requires-Dist: tensornetwork; extra == "dev"
|
|
24
|
+
Requires-Dist: quimb; extra == "dev"
|
|
25
|
+
Requires-Dist: physics-tenpy; extra == "dev"
|
|
26
|
+
Provides-Extra: tensorkrowch
|
|
27
|
+
Requires-Dist: tensorkrowch; extra == "tensorkrowch"
|
|
28
|
+
Provides-Extra: tensornetwork
|
|
29
|
+
Requires-Dist: tensornetwork; extra == "tensornetwork"
|
|
30
|
+
Provides-Extra: quimb
|
|
31
|
+
Requires-Dist: quimb; extra == "quimb"
|
|
32
|
+
Provides-Extra: tenpy
|
|
33
|
+
Requires-Dist: physics-tenpy; extra == "tenpy"
|
|
34
|
+
Provides-Extra: einsum
|
|
35
|
+
Requires-Dist: torch; extra == "einsum"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# Tensor-Network-Visualization
|
|
39
|
+
|
|
40
|
+
Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced
|
|
41
|
+
PyTorch/NumPy `einsum` tensor networks.
|
|
42
|
+
|
|
43
|
+
**Repository:** [https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization)
|
|
44
|
+
|
|
45
|
+
## What It Does
|
|
46
|
+
|
|
47
|
+
- renders tensor networks in `2d` or `3d`
|
|
48
|
+
- works with multiple tensor-network ecosystems through one shared API
|
|
49
|
+
- returns standard Matplotlib `Figure` and `Axes` objects for further customization
|
|
50
|
+
- can also reconstruct and render tensor networks from traced binary `einsum` contractions
|
|
51
|
+
|
|
52
|
+
There is no custom UI layer. The package builds a normalized graph and draws it with Matplotlib.
|
|
53
|
+
|
|
54
|
+
## Supported Engines
|
|
55
|
+
|
|
56
|
+
- `tensorkrowch`
|
|
57
|
+
- `tensornetwork`
|
|
58
|
+
- `quimb`
|
|
59
|
+
- `tenpy`
|
|
60
|
+
- `einsum`
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
- Extended guide: [`docs/guide.md`](docs/guide.md)
|
|
65
|
+
- Examples catalog: [`examples/README.md`](examples/README.md)
|
|
66
|
+
- Third-party licenses: [`THIRD_PARTY_LICENSES.md`](THIRD_PARTY_LICENSES.md)
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
### As a dependency
|
|
71
|
+
|
|
72
|
+
The base package includes the shared rendering core. Install the extra that matches the backend you
|
|
73
|
+
want to visualize:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install "tensor-network-visualization[tensorkrowch]"
|
|
77
|
+
pip install "tensor-network-visualization[tensornetwork]"
|
|
78
|
+
pip install "tensor-network-visualization[quimb]"
|
|
79
|
+
pip install "tensor-network-visualization[tenpy]"
|
|
80
|
+
pip install "tensor-network-visualization[einsum]"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`[einsum]` installs PyTorch for executing traced contractions. If you already have NumPy and only
|
|
84
|
+
need to render an existing trace, the base package is enough.
|
|
85
|
+
|
|
86
|
+
### Local development
|
|
87
|
+
|
|
88
|
+
Inside the project virtual environment:
|
|
89
|
+
|
|
90
|
+
```powershell
|
|
91
|
+
.\.venv\Scripts\python -m pip install -e ".[dev]"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Runtime-only editable install:
|
|
95
|
+
|
|
96
|
+
```powershell
|
|
97
|
+
.\.venv\Scripts\python -m pip install -e .
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The repository also keeps:
|
|
101
|
+
|
|
102
|
+
- `requirements.txt` -> `-e .`
|
|
103
|
+
- `requirements.dev.txt` -> `-e ".[dev]"`
|
|
104
|
+
|
|
105
|
+
These are thin wrappers around the editable installs above.
|
|
106
|
+
|
|
107
|
+
## Quick Start
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from tensor_network_viz import PlotConfig, show_tensor_network
|
|
111
|
+
|
|
112
|
+
config = PlotConfig(figsize=(8, 6))
|
|
113
|
+
|
|
114
|
+
fig, ax = show_tensor_network(
|
|
115
|
+
network,
|
|
116
|
+
engine="tensorkrowch",
|
|
117
|
+
view="2d",
|
|
118
|
+
config=config,
|
|
119
|
+
show=False,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
ax.set_title("My tensor network")
|
|
123
|
+
fig.savefig("network.png", bbox_inches="tight")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`show_tensor_network(...)` is the main dispatcher. You provide:
|
|
127
|
+
|
|
128
|
+
- `network`: the backend-native object or node/tensor collection
|
|
129
|
+
- `engine`: which backend adapter to use
|
|
130
|
+
- `view`: `2d` or `3d`
|
|
131
|
+
- `config`: optional `PlotConfig`
|
|
132
|
+
- `show=False` if you want to save or modify the figure before displaying it
|
|
133
|
+
|
|
134
|
+
The function returns `(fig, ax)`.
|
|
135
|
+
|
|
136
|
+
## Public API
|
|
137
|
+
|
|
138
|
+
From the root package:
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from tensor_network_viz import (
|
|
142
|
+
EinsumTrace,
|
|
143
|
+
PlotConfig,
|
|
144
|
+
einsum,
|
|
145
|
+
pair_tensor,
|
|
146
|
+
show_tensor_network,
|
|
147
|
+
)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Engine-specific helpers are also available:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from tensor_network_viz.tensorkrowch import plot_tensorkrowch_network_2d
|
|
154
|
+
from tensor_network_viz.tensornetwork import plot_tensornetwork_network_3d
|
|
155
|
+
from tensor_network_viz.quimb import plot_quimb_network_2d
|
|
156
|
+
from tensor_network_viz.tenpy import plot_tenpy_network_3d
|
|
157
|
+
from tensor_network_viz.einsum_module import plot_einsum_network_2d
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Accepted Inputs at a Glance
|
|
161
|
+
|
|
162
|
+
- `tensorkrowch`: a network object with `nodes` or `leaf_nodes`, or an iterable of nodes
|
|
163
|
+
- `tensornetwork`: an iterable of `tensornetwork.Node`
|
|
164
|
+
- `quimb`: a `TensorNetwork` or an iterable of `Tensor`
|
|
165
|
+
- `tenpy`: finite, segment, or infinite `MPS`, and finite or infinite `MPO`
|
|
166
|
+
- `einsum`: an `EinsumTrace` or an ordered iterable of `pair_tensor`
|
|
167
|
+
|
|
168
|
+
See the extended guide for backend-specific details and caveats.
|
|
169
|
+
|
|
170
|
+
## Plot Configuration
|
|
171
|
+
|
|
172
|
+
`PlotConfig` controls figure size, colors, line widths, label visibility, scale parameters, custom
|
|
173
|
+
positions, and layout iterations.
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from tensor_network_viz import PlotConfig
|
|
177
|
+
|
|
178
|
+
config = PlotConfig(
|
|
179
|
+
figsize=(10, 6),
|
|
180
|
+
show_tensor_labels=True,
|
|
181
|
+
show_index_labels=True,
|
|
182
|
+
layout_iterations=300,
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Important options:
|
|
187
|
+
|
|
188
|
+
- `positions`: custom node positions keyed by node id
|
|
189
|
+
- `validate_positions=True`: warn about unknown ids or wrong coordinate dimensions
|
|
190
|
+
- `layout_iterations`: tune the force-directed fallback layout
|
|
191
|
+
|
|
192
|
+
## Important Backend Notes
|
|
193
|
+
|
|
194
|
+
- Quimb hyper-indices shared by more than two tensors are rendered through internal virtual hubs.
|
|
195
|
+
- Infinite TeNPy `MPS` and `MPO` objects are drawn as one periodic unit cell.
|
|
196
|
+
- The `einsum` backend reconstructs the network of fundamental tensors rather than plotting
|
|
197
|
+
intermediate contraction results.
|
|
198
|
+
- If you pass only a subset of nodes/tensors, connections to outside objects appear as dangling
|
|
199
|
+
legs.
|
|
200
|
+
- Disconnected components are supported.
|
|
201
|
+
|
|
202
|
+
## Examples
|
|
203
|
+
|
|
204
|
+
The repository includes runnable scripts for every backend plus an extra TensorKrowch TSP example.
|
|
205
|
+
See [`examples/README.md`](examples/README.md) for commands and a short explanation of each script.
|
|
206
|
+
|
|
207
|
+
## Development
|
|
208
|
+
|
|
209
|
+
```powershell
|
|
210
|
+
.\.venv\Scripts\python -m ruff check .
|
|
211
|
+
.\.venv\Scripts\python -m pyright
|
|
212
|
+
.\.venv\Scripts\python -m pytest
|
|
213
|
+
```
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Tensor-Network-Visualization
|
|
2
|
+
|
|
3
|
+
Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced
|
|
4
|
+
PyTorch/NumPy `einsum` tensor networks.
|
|
5
|
+
|
|
6
|
+
**Repository:** [https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization)
|
|
7
|
+
|
|
8
|
+
## What It Does
|
|
9
|
+
|
|
10
|
+
- renders tensor networks in `2d` or `3d`
|
|
11
|
+
- works with multiple tensor-network ecosystems through one shared API
|
|
12
|
+
- returns standard Matplotlib `Figure` and `Axes` objects for further customization
|
|
13
|
+
- can also reconstruct and render tensor networks from traced binary `einsum` contractions
|
|
14
|
+
|
|
15
|
+
There is no custom UI layer. The package builds a normalized graph and draws it with Matplotlib.
|
|
16
|
+
|
|
17
|
+
## Supported Engines
|
|
18
|
+
|
|
19
|
+
- `tensorkrowch`
|
|
20
|
+
- `tensornetwork`
|
|
21
|
+
- `quimb`
|
|
22
|
+
- `tenpy`
|
|
23
|
+
- `einsum`
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
- Extended guide: [`docs/guide.md`](docs/guide.md)
|
|
28
|
+
- Examples catalog: [`examples/README.md`](examples/README.md)
|
|
29
|
+
- Third-party licenses: [`THIRD_PARTY_LICENSES.md`](THIRD_PARTY_LICENSES.md)
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### As a dependency
|
|
34
|
+
|
|
35
|
+
The base package includes the shared rendering core. Install the extra that matches the backend you
|
|
36
|
+
want to visualize:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install "tensor-network-visualization[tensorkrowch]"
|
|
40
|
+
pip install "tensor-network-visualization[tensornetwork]"
|
|
41
|
+
pip install "tensor-network-visualization[quimb]"
|
|
42
|
+
pip install "tensor-network-visualization[tenpy]"
|
|
43
|
+
pip install "tensor-network-visualization[einsum]"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`[einsum]` installs PyTorch for executing traced contractions. If you already have NumPy and only
|
|
47
|
+
need to render an existing trace, the base package is enough.
|
|
48
|
+
|
|
49
|
+
### Local development
|
|
50
|
+
|
|
51
|
+
Inside the project virtual environment:
|
|
52
|
+
|
|
53
|
+
```powershell
|
|
54
|
+
.\.venv\Scripts\python -m pip install -e ".[dev]"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Runtime-only editable install:
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
|
+
.\.venv\Scripts\python -m pip install -e .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The repository also keeps:
|
|
64
|
+
|
|
65
|
+
- `requirements.txt` -> `-e .`
|
|
66
|
+
- `requirements.dev.txt` -> `-e ".[dev]"`
|
|
67
|
+
|
|
68
|
+
These are thin wrappers around the editable installs above.
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from tensor_network_viz import PlotConfig, show_tensor_network
|
|
74
|
+
|
|
75
|
+
config = PlotConfig(figsize=(8, 6))
|
|
76
|
+
|
|
77
|
+
fig, ax = show_tensor_network(
|
|
78
|
+
network,
|
|
79
|
+
engine="tensorkrowch",
|
|
80
|
+
view="2d",
|
|
81
|
+
config=config,
|
|
82
|
+
show=False,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
ax.set_title("My tensor network")
|
|
86
|
+
fig.savefig("network.png", bbox_inches="tight")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`show_tensor_network(...)` is the main dispatcher. You provide:
|
|
90
|
+
|
|
91
|
+
- `network`: the backend-native object or node/tensor collection
|
|
92
|
+
- `engine`: which backend adapter to use
|
|
93
|
+
- `view`: `2d` or `3d`
|
|
94
|
+
- `config`: optional `PlotConfig`
|
|
95
|
+
- `show=False` if you want to save or modify the figure before displaying it
|
|
96
|
+
|
|
97
|
+
The function returns `(fig, ax)`.
|
|
98
|
+
|
|
99
|
+
## Public API
|
|
100
|
+
|
|
101
|
+
From the root package:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from tensor_network_viz import (
|
|
105
|
+
EinsumTrace,
|
|
106
|
+
PlotConfig,
|
|
107
|
+
einsum,
|
|
108
|
+
pair_tensor,
|
|
109
|
+
show_tensor_network,
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Engine-specific helpers are also available:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from tensor_network_viz.tensorkrowch import plot_tensorkrowch_network_2d
|
|
117
|
+
from tensor_network_viz.tensornetwork import plot_tensornetwork_network_3d
|
|
118
|
+
from tensor_network_viz.quimb import plot_quimb_network_2d
|
|
119
|
+
from tensor_network_viz.tenpy import plot_tenpy_network_3d
|
|
120
|
+
from tensor_network_viz.einsum_module import plot_einsum_network_2d
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Accepted Inputs at a Glance
|
|
124
|
+
|
|
125
|
+
- `tensorkrowch`: a network object with `nodes` or `leaf_nodes`, or an iterable of nodes
|
|
126
|
+
- `tensornetwork`: an iterable of `tensornetwork.Node`
|
|
127
|
+
- `quimb`: a `TensorNetwork` or an iterable of `Tensor`
|
|
128
|
+
- `tenpy`: finite, segment, or infinite `MPS`, and finite or infinite `MPO`
|
|
129
|
+
- `einsum`: an `EinsumTrace` or an ordered iterable of `pair_tensor`
|
|
130
|
+
|
|
131
|
+
See the extended guide for backend-specific details and caveats.
|
|
132
|
+
|
|
133
|
+
## Plot Configuration
|
|
134
|
+
|
|
135
|
+
`PlotConfig` controls figure size, colors, line widths, label visibility, scale parameters, custom
|
|
136
|
+
positions, and layout iterations.
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from tensor_network_viz import PlotConfig
|
|
140
|
+
|
|
141
|
+
config = PlotConfig(
|
|
142
|
+
figsize=(10, 6),
|
|
143
|
+
show_tensor_labels=True,
|
|
144
|
+
show_index_labels=True,
|
|
145
|
+
layout_iterations=300,
|
|
146
|
+
)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Important options:
|
|
150
|
+
|
|
151
|
+
- `positions`: custom node positions keyed by node id
|
|
152
|
+
- `validate_positions=True`: warn about unknown ids or wrong coordinate dimensions
|
|
153
|
+
- `layout_iterations`: tune the force-directed fallback layout
|
|
154
|
+
|
|
155
|
+
## Important Backend Notes
|
|
156
|
+
|
|
157
|
+
- Quimb hyper-indices shared by more than two tensors are rendered through internal virtual hubs.
|
|
158
|
+
- Infinite TeNPy `MPS` and `MPO` objects are drawn as one periodic unit cell.
|
|
159
|
+
- The `einsum` backend reconstructs the network of fundamental tensors rather than plotting
|
|
160
|
+
intermediate contraction results.
|
|
161
|
+
- If you pass only a subset of nodes/tensors, connections to outside objects appear as dangling
|
|
162
|
+
legs.
|
|
163
|
+
- Disconnected components are supported.
|
|
164
|
+
|
|
165
|
+
## Examples
|
|
166
|
+
|
|
167
|
+
The repository includes runnable scripts for every backend plus an extra TensorKrowch TSP example.
|
|
168
|
+
See [`examples/README.md`](examples/README.md) for commands and a short explanation of each script.
|
|
169
|
+
|
|
170
|
+
## Development
|
|
171
|
+
|
|
172
|
+
```powershell
|
|
173
|
+
.\.venv\Scripts\python -m ruff check .
|
|
174
|
+
.\.venv\Scripts\python -m pyright
|
|
175
|
+
.\.venv\Scripts\python -m pytest
|
|
176
|
+
```
|
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=68"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "tensor-network-visualization"
|
|
7
|
-
version = "1.
|
|
8
|
-
description = "Minimal Matplotlib visualizations for TensorKrowch tensor networks."
|
|
9
|
-
authors = [{ name = "Alejandro Mata Ali" }]
|
|
10
|
-
readme = "README.md"
|
|
11
|
-
license = { text = "MIT" }
|
|
12
|
-
requires-python = ">=3.10"
|
|
13
|
-
keywords = ["tensor-network", "visualization", "tensorkrowch", "matplotlib"]
|
|
14
|
-
dependencies = [
|
|
15
|
-
"matplotlib>=3.7",
|
|
16
|
-
"networkx>=3.0",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"Programming Language :: Python :: 3",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
[
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
[
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tensor-network-visualization"
|
|
7
|
+
version = "1.3.0"
|
|
8
|
+
description = "Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, and TeNPy tensor networks."
|
|
9
|
+
authors = [{ name = "Alejandro Mata Ali" }]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
keywords = ["tensor-network", "visualization", "tensorkrowch", "tensornetwork", "quimb", "tenpy", "matplotlib"]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"matplotlib>=3.7",
|
|
16
|
+
"networkx>=3.0",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Repository = "https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization"
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
dev = ["pytest", "ruff", "pyright", "tensorkrowch", "tensornetwork", "quimb", "physics-tenpy"]
|
|
30
|
+
tensorkrowch = ["tensorkrowch"]
|
|
31
|
+
tensornetwork = ["tensornetwork"]
|
|
32
|
+
quimb = ["quimb"]
|
|
33
|
+
tenpy = ["physics-tenpy"]
|
|
34
|
+
einsum = ["torch"]
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.packages.find]
|
|
37
|
+
where = ["src"]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.package-data]
|
|
40
|
+
tensor_network_viz = ["py.typed"]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
testpaths = ["tests"]
|
|
44
|
+
addopts = "-p no:cacheprovider"
|
|
45
|
+
pythonpath = ["src"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 100
|
|
49
|
+
target-version = "py310"
|
|
50
|
+
src = ["src", "tests"]
|
|
51
|
+
exclude = [".venv", ".tmp", ".pip_tmp", ".pytest_cache", ".ruff_cache", "pytest-cache-files-*", "tn_tsp.py"]
|
|
52
|
+
|
|
53
|
+
[tool.ruff.lint]
|
|
54
|
+
select = ["E", "F", "I", "B", "UP", "C4", "SIM"]
|