tensor-network-visualization 2.0.2__py3-none-any.whl → 2.0.4__py3-none-any.whl

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.
Files changed (115) hide show
  1. {tensor_network_visualization-2.0.2.dist-info → tensor_network_visualization-2.0.4.dist-info}/METADATA +307 -296
  2. tensor_network_visualization-2.0.4.dist-info/RECORD +122 -0
  3. {tensor_network_visualization-2.0.2.dist-info → tensor_network_visualization-2.0.4.dist-info}/WHEEL +1 -1
  4. tensor_network_viz/__init__.py +276 -276
  5. tensor_network_viz/_auto_display.py +54 -54
  6. tensor_network_viz/_contraction_viewer_style.py +202 -202
  7. tensor_network_viz/_contraction_viewer_ui.py +149 -149
  8. tensor_network_viz/_core/_draw_common.py +9 -9
  9. tensor_network_viz/_core/_label_format.py +195 -195
  10. tensor_network_viz/_core/_nodes_edges_common.py +174 -174
  11. tensor_network_viz/_core/axis_directions.py +50 -50
  12. tensor_network_viz/_core/contractions.py +114 -114
  13. tensor_network_viz/_core/curves.py +64 -64
  14. tensor_network_viz/_core/draw/__init__.py +46 -46
  15. tensor_network_viz/_core/draw/constants.py +138 -138
  16. tensor_network_viz/_core/draw/contraction_edges.py +152 -152
  17. tensor_network_viz/_core/draw/contraction_scheme.py +884 -884
  18. tensor_network_viz/_core/draw/dangling_self_edges.py +490 -490
  19. tensor_network_viz/_core/draw/edge_labels.py +150 -150
  20. tensor_network_viz/_core/draw/edges.py +16 -16
  21. tensor_network_viz/_core/draw/fonts_and_scale.py +315 -315
  22. tensor_network_viz/_core/draw/graph_pipeline.py +266 -266
  23. tensor_network_viz/_core/draw/hover.py +426 -426
  24. tensor_network_viz/_core/draw/label_descriptors.py +56 -56
  25. tensor_network_viz/_core/draw/labels_misc.py +167 -167
  26. tensor_network_viz/_core/draw/plotter.py +68 -68
  27. tensor_network_viz/_core/draw/plotter_2d.py +229 -229
  28. tensor_network_viz/_core/draw/plotter_3d.py +209 -209
  29. tensor_network_viz/_core/draw/plotter_common.py +85 -85
  30. tensor_network_viz/_core/draw/render_prep.py +595 -595
  31. tensor_network_viz/_core/draw/scene_state.py +70 -70
  32. tensor_network_viz/_core/draw/tensors.py +299 -299
  33. tensor_network_viz/_core/draw/vectors.py +39 -39
  34. tensor_network_viz/_core/draw/viewport_geometry.py +732 -732
  35. tensor_network_viz/_core/focus.py +323 -323
  36. tensor_network_viz/_core/graph.py +325 -325
  37. tensor_network_viz/_core/graph_cache.py +206 -206
  38. tensor_network_viz/_core/layout/__init__.py +17 -17
  39. tensor_network_viz/_core/layout/body.py +150 -150
  40. tensor_network_viz/_core/layout/direction_common.py +550 -550
  41. tensor_network_viz/_core/layout/force_directed.py +247 -247
  42. tensor_network_viz/_core/layout/free_directions_2d.py +1096 -1096
  43. tensor_network_viz/_core/layout/free_directions_3d.py +844 -844
  44. tensor_network_viz/_core/layout/generic_coarsening.py +779 -779
  45. tensor_network_viz/_core/layout/geometry.py +403 -403
  46. tensor_network_viz/_core/layout/parameters.py +64 -64
  47. tensor_network_viz/_core/layout/positions.py +1199 -1199
  48. tensor_network_viz/_core/layout/types.py +13 -13
  49. tensor_network_viz/_core/layout_structure.py +1117 -1095
  50. tensor_network_viz/_core/layout_structure_coordinates.py +208 -208
  51. tensor_network_viz/_core/layout_structure_sparse_grid.py +222 -222
  52. tensor_network_viz/_core/renderer.py +633 -632
  53. tensor_network_viz/_engine_specs.py +44 -44
  54. tensor_network_viz/_import_state.py +37 -37
  55. tensor_network_viz/_input_inspection.py +538 -538
  56. tensor_network_viz/_interaction/__init__.py +3 -3
  57. tensor_network_viz/_interaction/bridge.py +180 -180
  58. tensor_network_viz/_interaction/controller.py +912 -909
  59. tensor_network_viz/_interaction/controls.py +369 -369
  60. tensor_network_viz/_interaction/scheme.py +234 -234
  61. tensor_network_viz/_interaction/state.py +155 -155
  62. tensor_network_viz/_interaction/tensor_inspector.py +760 -760
  63. tensor_network_viz/_interaction/views.py +219 -217
  64. tensor_network_viz/_interactive_scene.py +762 -762
  65. tensor_network_viz/_logging.py +16 -16
  66. tensor_network_viz/_matplotlib_state.py +84 -84
  67. tensor_network_viz/_registry.py +86 -86
  68. tensor_network_viz/_tensor_comparison_support.py +147 -147
  69. tensor_network_viz/_tensor_elements_controller.py +1148 -1148
  70. tensor_network_viz/_tensor_elements_data.py +862 -859
  71. tensor_network_viz/_tensor_elements_inputs.py +586 -586
  72. tensor_network_viz/_tensor_elements_models.py +137 -137
  73. tensor_network_viz/_tensor_elements_payloads.py +913 -913
  74. tensor_network_viz/_tensor_elements_rendering.py +341 -340
  75. tensor_network_viz/_tensor_elements_support.py +55 -55
  76. tensor_network_viz/_translation_codegen.py +322 -322
  77. tensor_network_viz/_translation_models.py +41 -41
  78. tensor_network_viz/_typing.py +31 -31
  79. tensor_network_viz/_ui_utils.py +157 -157
  80. tensor_network_viz/_widgets.py +38 -38
  81. tensor_network_viz/config.py +355 -355
  82. tensor_network_viz/contraction_viewer.py +1013 -1003
  83. tensor_network_viz/einsum_module/__init__.py +46 -46
  84. tensor_network_viz/einsum_module/_backend.py +57 -57
  85. tensor_network_viz/einsum_module/_equation.py +332 -332
  86. tensor_network_viz/einsum_module/_trace_state.py +302 -302
  87. tensor_network_viz/einsum_module/_trace_types.py +77 -77
  88. tensor_network_viz/einsum_module/contraction_cost.py +170 -170
  89. tensor_network_viz/einsum_module/graph.py +381 -381
  90. tensor_network_viz/einsum_module/renderer.py +17 -17
  91. tensor_network_viz/einsum_module/trace.py +177 -177
  92. tensor_network_viz/exceptions.py +47 -47
  93. tensor_network_viz/interactive_viewer.py +7 -7
  94. tensor_network_viz/quimb/__init__.py +32 -32
  95. tensor_network_viz/quimb/graph.py +165 -165
  96. tensor_network_viz/quimb/renderer.py +17 -17
  97. tensor_network_viz/snapshot.py +353 -353
  98. tensor_network_viz/tenpy/__init__.py +37 -37
  99. tensor_network_viz/tenpy/explicit.py +73 -73
  100. tensor_network_viz/tenpy/graph.py +197 -197
  101. tensor_network_viz/tenpy/renderer.py +17 -17
  102. tensor_network_viz/tensor_comparison.py +244 -244
  103. tensor_network_viz/tensor_comparison_config.py +42 -42
  104. tensor_network_viz/tensor_elements.py +301 -301
  105. tensor_network_viz/tensor_elements_config.py +308 -308
  106. tensor_network_viz/tensorkrowch/__init__.py +32 -32
  107. tensor_network_viz/tensorkrowch/_history.py +395 -395
  108. tensor_network_viz/tensorkrowch/graph.py +40 -40
  109. tensor_network_viz/tensornetwork/__init__.py +32 -32
  110. tensor_network_viz/tensornetwork/graph.py +20 -20
  111. tensor_network_viz/translation.py +262 -262
  112. tensor_network_viz/viewer.py +253 -253
  113. tensor_network_visualization-2.0.2.dist-info/RECORD +0 -122
  114. {tensor_network_visualization-2.0.2.dist-info → tensor_network_visualization-2.0.4.dist-info}/licenses/LICENSE +0 -0
  115. {tensor_network_visualization-2.0.2.dist-info → tensor_network_visualization-2.0.4.dist-info}/top_level.txt +0 -0
@@ -1,296 +1,307 @@
1
- Metadata-Version: 2.4
2
- Name: tensor-network-visualization
3
- Version: 2.0.2
4
- Summary: Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced PyTorch/NumPy einsum tensor networks.
5
- Author: Alejandro Mata Ali
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization
8
- Project-URL: Documentation, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/blob/main/docs/guide.md
9
- Project-URL: Changelog, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/blob/main/CHANGELOG.md
10
- Project-URL: Repository, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization
11
- Project-URL: Issues, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/issues
12
- Keywords: tensor-network,visualization,pytorch,numpy,tensorkrowch,tensornetwork,quimb,tenpy,einsum,quantum-inspired,matplotlib
13
- Classifier: Development Status :: 5 - Production/Stable
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: Operating System :: OS Independent
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3 :: Only
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: Programming Language :: Python :: 3.12
20
- Classifier: Programming Language :: Python :: 3.13
21
- Classifier: Topic :: Scientific/Engineering :: Visualization
22
- Classifier: Typing :: Typed
23
- Requires-Python: >=3.11
24
- Description-Content-Type: text/markdown
25
- License-File: LICENSE
26
- Requires-Dist: matplotlib>=3.7
27
- Requires-Dist: networkx>=3.0
28
- Requires-Dist: numpy>=2.0
29
- Provides-Extra: dev
30
- Requires-Dist: build; extra == "dev"
31
- Requires-Dist: pytest; extra == "dev"
32
- Requires-Dist: ruff; extra == "dev"
33
- Requires-Dist: pyright; extra == "dev"
34
- Requires-Dist: ipython; extra == "dev"
35
- Requires-Dist: tensorkrowch; extra == "dev"
36
- Requires-Dist: tensornetwork; extra == "dev"
37
- Requires-Dist: quimb; extra == "dev"
38
- Requires-Dist: physics-tenpy; extra == "dev"
39
- Provides-Extra: jupyter
40
- Requires-Dist: ipympl>=0.9.0; extra == "jupyter"
41
- Requires-Dist: ipywidgets>=8.0; extra == "jupyter"
42
- Requires-Dist: jupyterlab>=4.0; extra == "jupyter"
43
- Requires-Dist: notebook>=7.0; extra == "jupyter"
44
- Provides-Extra: tensorkrowch
45
- Requires-Dist: tensorkrowch; extra == "tensorkrowch"
46
- Provides-Extra: tensornetwork
47
- Requires-Dist: tensornetwork; extra == "tensornetwork"
48
- Provides-Extra: quimb
49
- Requires-Dist: quimb; extra == "quimb"
50
- Provides-Extra: tenpy
51
- Requires-Dist: physics-tenpy; extra == "tenpy"
52
- Provides-Extra: einsum
53
- Requires-Dist: torch; extra == "einsum"
54
- Dynamic: license-file
55
-
56
- <p align="center">
57
- <img
58
- src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/tensor_network_visualization_logo.png"
59
- alt="Tensor-Network-Visualization logo"
60
- width="420"
61
- >
62
- </p>
63
-
64
- # Tensor-Network-Visualization
65
-
66
- [![CI](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/actions/workflows/ci.yml/badge.svg)](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/actions/workflows/ci.yml)
67
- [![PyPI version](https://img.shields.io/pypi/v/tensor-network-visualization.svg)](https://pypi.org/project/tensor-network-visualization/)
68
- [![Python versions](https://img.shields.io/pypi/pyversions/tensor-network-visualization.svg)](https://pypi.org/project/tensor-network-visualization/)
69
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
70
-
71
- Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced
72
- PyTorch/NumPy `einsum` tensor networks.
73
-
74
- ## Gallery
75
-
76
- These are exports generated with the library and the repository demos.
77
-
78
- <p align="center">
79
- <img
80
- src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/cubic_peps_3d.png"
81
- alt="Cubic PEPS 3D tensor network visualization"
82
- width="230"
83
- >
84
- <img
85
- src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/mera_2d.png"
86
- alt="MERA 2D tensor network visualization with labels"
87
- width="230"
88
- >
89
- <img
90
- src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/tubular_grid_3d.png"
91
- alt="Tubular 3D tensor network visualization"
92
- width="230"
93
- >
94
- </p>
95
-
96
- <p align="center">
97
- <img
98
- src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/network_controls.png"
99
- alt="MPS with controls, tensor labels, and index labels"
100
- width="230"
101
- >
102
- <img
103
- src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/tensor_elements_phase.png"
104
- alt="Tensor elements phase visualization"
105
- width="230"
106
- >
107
- <img
108
- src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/tensor_elements_controls.png"
109
- alt="Tensor elements view with the full control menus"
110
- width="230"
111
- >
112
- </p>
113
-
114
- ## Why This Exists
115
-
116
- Tensor-network libraries expose different Python objects. This package gives them a small shared
117
- visualization API so you can inspect structure, tensor values, contraction playback, and normalized
118
- graph exports without rewriting plotting code for every backend.
119
-
120
- The common entry points are:
121
-
122
- ```python
123
- show_tensor_network(...)
124
- show_tensor_elements(...)
125
- show_tensor_comparison(...)
126
- translate_tensor_network(...)
127
- normalize_tensor_network(...)
128
- export_tensor_network_snapshot(...)
129
- ```
130
-
131
- If you want code for another backend rather than a figure, `translate_tensor_network(...)` can turn
132
- supported TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced `einsum` inputs into executable
133
- Python for `tensornetwork`, `quimb`, `einsum`, or `tensorkrowch`.
134
-
135
- ## Install
136
-
137
- - PyPI package name: `tensor-network-visualization`
138
- - Import package: `tensor_network_viz`
139
- - Requires Python 3.11 or newer.
140
-
141
- ```bash
142
- python -m pip install tensor-network-visualization
143
- ```
144
-
145
- The base install only depends on `numpy`, `matplotlib`, and `networkx`.
146
-
147
- For interactive Jupyter figures:
148
-
149
- ```bash
150
- python -m pip install "tensor-network-visualization[jupyter]"
151
- ```
152
-
153
- For backend-specific packages, install the matching extra, for example:
154
-
155
- ```bash
156
- python -m pip install "tensor-network-visualization[quimb]"
157
- ```
158
-
159
- See [docs/installation.md](docs/installation.md) for virtual environments, all optional extras, and
160
- local development installs.
161
-
162
- ## Basic Usage
163
-
164
- ### NumPy `einsum` trace (base install)
165
-
166
- This example uses only base dependencies and a NumPy-backed `EinsumTrace`.
167
-
168
- ```python
169
- import numpy as np
170
- from tensor_network_viz import EinsumTrace, PlotConfig, einsum, show_tensor_network
171
-
172
- trace = EinsumTrace()
173
- a = np.ones((2, 3), dtype=float)
174
- x = np.array([1.0, -0.5, 0.25], dtype=float)
175
-
176
- trace.bind("A", a)
177
- trace.bind("x", x)
178
- einsum("ab,b->a", a, x, trace=trace, backend="numpy")
179
-
180
- fig, ax = show_tensor_network(
181
- trace,
182
- config=PlotConfig(show_tensor_labels=True, hover_labels=True),
183
- show=False,
184
- )
185
- fig.savefig("einsum-network.png", bbox_inches="tight")
186
- ```
187
-
188
- ### TensorKrowch
189
-
190
- Install the TensorKrowch extra (see [Installation](docs/installation.md) for details):
191
-
192
- ```bash
193
- python -m pip install "tensor-network-visualization[tensorkrowch]"
194
- ```
195
-
196
- ```python
197
- import tensorkrowch as tk
198
- from tensor_network_viz import PlotConfig, show_tensor_network
199
-
200
- network = tk.TensorNetwork(name="demo")
201
- left = tk.Node(shape=(2, 2), axes_names=("a", "b"), name="L", network=network)
202
- right = tk.Node(shape=(2, 2), axes_names=("b", "c"), name="R", network=network)
203
- left["b"] ^ right["b"]
204
-
205
- fig, ax = show_tensor_network(
206
- network,
207
- config=PlotConfig(show_tensor_labels=True, show_index_labels=False),
208
- show=False,
209
- )
210
- fig.savefig("tensorkrowch-network.png", bbox_inches="tight")
211
- ```
212
-
213
- Use `show=False` when you want to save or customize the figure yourself. Use
214
- `show_controls=False` when you want a clean static figure with no embedded Matplotlib controls.
215
-
216
- In a notebook, use this exact recipe:
217
-
218
- ```python
219
- %pip install "tensor-network-visualization[jupyter]"
220
- ```
221
-
222
- If you just installed that extra in the current kernel, restart the kernel once. Then, in the
223
- first plotting cell:
224
-
225
- ```python
226
- %matplotlib widget
227
-
228
- from tensor_network_viz import PlotConfig, show_tensor_network
229
-
230
- fig, ax = show_tensor_network(
231
- network,
232
- config=PlotConfig(show_tensor_labels=True, hover_labels=True),
233
- )
234
- ```
235
-
236
- See [Installation](docs/installation.md) and [User Guide](docs/guide.md) for details.
237
-
238
- ## Documentation
239
-
240
- - [Installation](docs/installation.md): virtual environments, optional extras, Jupyter, and local
241
- editable installs.
242
- - [API Reference](docs/api.md): public functions, configuration objects, snapshots, exceptions, and
243
- logging.
244
- - [User Guide](docs/guide.md): workflows, notebooks, exports, layouts, tensor inspection,
245
- comparisons, snapshots, and performance tips.
246
- - [Layout Algorithms](docs/algorithms.md): node placement and free-edge direction rules in 2D and
247
- 3D.
248
- - [Backend Examples](docs/backends.md): copy-paste examples for TensorKrowch, TensorNetwork, Quimb,
249
- TeNPy, and `einsum`.
250
- - [Troubleshooting](docs/troubleshooting.md): common install, Jupyter, Matplotlib, backend, and data
251
- issues.
252
- - [Repository Examples](examples/README.md): command-line demo launcher and example catalog.
253
- - [Demo Commands](commands.md): copy-paste commands for every repository demo.
254
-
255
- ## Demo Gallery
256
-
257
- The repository examples are organized around the same launcher:
258
-
259
- ```bash
260
- python examples/run_demo.py <group> <demo>
261
- ```
262
-
263
- The gallery includes backend demos for TensorKrowch, TensorNetwork, Quimb, TeNPy, and `einsum`,
264
- plus three focused groups:
265
-
266
- - `themes overview`: compares the `PlotConfig` visual presets for tensor-network figures.
267
- - `themes tensor_elements`: compares the `TensorElementsConfig` presets for `show_tensor_elements(...)`
268
- and the linked tensor inspector.
269
- - `placements`: shows object, list, 2D grid, 3D grid, manual positions, manual schemes, and named
270
- index inputs.
271
- - `geometry`: renders larger irregular, incomplete, triangular, pyramidal, circular, and
272
- disconnected networks.
273
-
274
- There is also a dedicated translation demo:
275
-
276
- ```bash
277
- python examples/translate_demo.py --source-engine tensornetwork --target-engine quimb --example mps
278
- ```
279
-
280
- It generates Python code for the translated tensor network and can render the original and
281
- translated versions side by side for comparison.
282
-
283
- For batch checks, use:
284
-
285
- ```bash
286
- python examples/run_all_examples.py --group engines --views 2d --list
287
- python examples/run_all_examples.py --group all --views 2d --output-dir .tmp/examples
288
- ```
289
-
290
- ## Project Links
291
-
292
- - [Changelog](CHANGELOG.md)
293
- - [Contributing](CONTRIBUTING.md)
294
- - [Code of Conduct](CODE_OF_CONDUCT.md)
295
- - [Issues](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/issues)
296
- - [Repository](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization)
1
+ Metadata-Version: 2.4
2
+ Name: tensor-network-visualization
3
+ Version: 2.0.4
4
+ Summary: Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced PyTorch/NumPy einsum tensor networks.
5
+ Author: Alejandro Mata Ali
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization
8
+ Project-URL: Documentation, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/blob/main/docs/guide.md
9
+ Project-URL: Changelog, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/blob/main/CHANGELOG.md
10
+ Project-URL: Repository, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization
11
+ Project-URL: Issues, https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/issues
12
+ Keywords: tensor-network,visualization,pytorch,numpy,tensorkrowch,tensornetwork,quimb,tenpy,einsum,quantum-inspired,matplotlib
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Visualization
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: matplotlib>=3.11.2
27
+ Requires-Dist: networkx>=3.6.1; python_version < "3.12"
28
+ Requires-Dist: networkx>=3.7; python_version >= "3.12"
29
+ Requires-Dist: numpy>=2.4.5; python_version < "3.12"
30
+ Requires-Dist: numpy>=2.5.5; python_version >= "3.12"
31
+ Provides-Extra: dev
32
+ Requires-Dist: bandit>=1.9.4; extra == "dev"
33
+ Requires-Dist: build>=1.6.1; extra == "dev"
34
+ Requires-Dist: pytest>=9.2.0; extra == "dev"
35
+ Requires-Dist: ruff>=0.17.5; extra == "dev"
36
+ Requires-Dist: setuptools>=84.2.1; extra == "dev"
37
+ Requires-Dist: pyright>=1.1.414; extra == "dev"
38
+ Requires-Dist: pip-audit>=2.10.1; extra == "dev"
39
+ Requires-Dist: twine>=7.0.0; extra == "dev"
40
+ Requires-Dist: ipython>=9.18.1; extra == "dev"
41
+ Requires-Dist: tensorkrowch>=1.1; extra == "dev"
42
+ Requires-Dist: tensornetwork>=0.4; extra == "dev"
43
+ Requires-Dist: quimb>=1.7; extra == "dev"
44
+ Requires-Dist: physics-tenpy>=1.0.6; extra == "dev"
45
+ Provides-Extra: jupyter
46
+ Requires-Dist: ipympl>=0.9.0; extra == "jupyter"
47
+ Requires-Dist: ipywidgets>=8.0; extra == "jupyter"
48
+ Requires-Dist: jupyterlab>=4.0; extra == "jupyter"
49
+ Requires-Dist: notebook>=7.0; extra == "jupyter"
50
+ Provides-Extra: tensorkrowch
51
+ Requires-Dist: tensorkrowch>=1.1; extra == "tensorkrowch"
52
+ Provides-Extra: tensornetwork
53
+ Requires-Dist: tensornetwork>=0.4; extra == "tensornetwork"
54
+ Provides-Extra: quimb
55
+ Requires-Dist: quimb>=1.7; extra == "quimb"
56
+ Provides-Extra: tenpy
57
+ Requires-Dist: physics-tenpy>=1.0.6; extra == "tenpy"
58
+ Provides-Extra: einsum
59
+ Requires-Dist: torch>=2.0; extra == "einsum"
60
+ Dynamic: license-file
61
+
62
+ <p align="center">
63
+ <img
64
+ src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/tensor_network_visualization_logo.png"
65
+ alt="Tensor-Network-Visualization logo"
66
+ width="420"
67
+ >
68
+ </p>
69
+
70
+ <p align="center"><em>Logo:</em> original project artwork by Alejandro Mata Ali; covered by the same MIT license as this repository.</p>
71
+
72
+ # Tensor-Network-Visualization
73
+
74
+ [![CI](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/actions/workflows/ci.yml/badge.svg)](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/actions/workflows/ci.yml)
75
+ [![PyPI version](https://img.shields.io/pypi/v/tensor-network-visualization.svg)](https://pypi.org/project/tensor-network-visualization/)
76
+ [![Python versions](https://img.shields.io/pypi/pyversions/tensor-network-visualization.svg)](https://pypi.org/project/tensor-network-visualization/)
77
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
78
+
79
+ Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced
80
+ PyTorch/NumPy `einsum` tensor networks.
81
+
82
+ ## Gallery
83
+
84
+ These are exports generated with the library and the repository demos.
85
+
86
+ <p align="center">
87
+ <img
88
+ src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/cubic_peps_3d.png"
89
+ alt="Cubic PEPS 3D tensor network visualization"
90
+ width="230"
91
+ >
92
+ <img
93
+ src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/mera_2d.png"
94
+ alt="MERA 2D tensor network visualization with labels"
95
+ width="230"
96
+ >
97
+ <img
98
+ src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/tubular_grid_3d.png"
99
+ alt="Tubular 3D tensor network visualization"
100
+ width="230"
101
+ >
102
+ </p>
103
+
104
+ <p align="center">
105
+ <img
106
+ src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/network_controls.png"
107
+ alt="MPS with controls, tensor labels, and index labels"
108
+ width="230"
109
+ >
110
+ <img
111
+ src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/tensor_elements_phase.png"
112
+ alt="Tensor elements phase visualization"
113
+ width="230"
114
+ >
115
+ <img
116
+ src="https://raw.githubusercontent.com/DOKOS-TAYOS/Tensor-Network-Visualization/main/images/gallery/tensor_elements_controls.png"
117
+ alt="Tensor elements view with the full control menus"
118
+ width="230"
119
+ >
120
+ </p>
121
+
122
+ ## Why This Exists
123
+
124
+ Tensor-network libraries expose different Python objects. This package gives them a small shared
125
+ visualization API so you can inspect structure, tensor values, contraction playback, and normalized
126
+ graph exports without rewriting plotting code for every backend.
127
+
128
+ The common entry points are:
129
+
130
+ ```python
131
+ show_tensor_network(...)
132
+ show_tensor_elements(...)
133
+ show_tensor_comparison(...)
134
+ translate_tensor_network(...)
135
+ normalize_tensor_network(...)
136
+ export_tensor_network_snapshot(...)
137
+ ```
138
+
139
+ If you want code for another backend rather than a figure, `translate_tensor_network(...)` can turn
140
+ supported TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced `einsum` inputs into executable
141
+ Python for `tensornetwork`, `quimb`, `einsum`, or `tensorkrowch`.
142
+
143
+ ## Install
144
+
145
+ - PyPI package name: `tensor-network-visualization`
146
+ - Import package: `tensor_network_viz`
147
+ - Requires Python 3.11 or newer.
148
+
149
+ ```bash
150
+ python -m pip install tensor-network-visualization
151
+ ```
152
+
153
+ The base install only depends on `numpy`, `matplotlib`, and `networkx`.
154
+
155
+ For interactive Jupyter figures:
156
+
157
+ ```bash
158
+ python -m pip install "tensor-network-visualization[jupyter]"
159
+ ```
160
+
161
+ For backend-specific packages, install the matching extra, for example:
162
+
163
+ ```bash
164
+ python -m pip install "tensor-network-visualization[quimb]"
165
+ ```
166
+
167
+ See [docs/installation.md](docs/installation.md) for virtual environments, all optional extras, and
168
+ local development installs.
169
+
170
+ ## Basic Usage
171
+
172
+ ### NumPy `einsum` trace (base install)
173
+
174
+ This example uses only base dependencies and a NumPy-backed `EinsumTrace`.
175
+
176
+ ```python
177
+ import numpy as np
178
+ from tensor_network_viz import EinsumTrace, PlotConfig, einsum, show_tensor_network
179
+
180
+ trace = EinsumTrace()
181
+ a = np.ones((2, 3), dtype=float)
182
+ x = np.array([1.0, -0.5, 0.25], dtype=float)
183
+
184
+ trace.bind("A", a)
185
+ trace.bind("x", x)
186
+ einsum("ab,b->a", a, x, trace=trace, backend="numpy")
187
+
188
+ fig, ax = show_tensor_network(
189
+ trace,
190
+ config=PlotConfig(show_tensor_labels=True, hover_labels=True),
191
+ show=False,
192
+ )
193
+ fig.savefig("einsum-network.png", bbox_inches="tight")
194
+ ```
195
+
196
+ ### TensorKrowch
197
+
198
+ Install the TensorKrowch extra (see [Installation](docs/installation.md) for details):
199
+
200
+ ```bash
201
+ python -m pip install "tensor-network-visualization[tensorkrowch]"
202
+ ```
203
+
204
+ ```python
205
+ import tensorkrowch as tk
206
+ from tensor_network_viz import PlotConfig, show_tensor_network
207
+
208
+ network = tk.TensorNetwork(name="demo")
209
+ left = tk.Node(shape=(2, 2), axes_names=("a", "b"), name="L", network=network)
210
+ right = tk.Node(shape=(2, 2), axes_names=("b", "c"), name="R", network=network)
211
+ left["b"] ^ right["b"]
212
+
213
+ fig, ax = show_tensor_network(
214
+ network,
215
+ config=PlotConfig(show_tensor_labels=True, show_index_labels=False),
216
+ show=False,
217
+ )
218
+ fig.savefig("tensorkrowch-network.png", bbox_inches="tight")
219
+ ```
220
+
221
+ Use `show=False` when you want to save or customize the figure yourself. Use
222
+ `show_controls=False` when you want a clean static figure with no embedded Matplotlib controls.
223
+
224
+ In a notebook, use this exact recipe:
225
+
226
+ ```python
227
+ %pip install "tensor-network-visualization[jupyter]"
228
+ ```
229
+
230
+ If you just installed that extra in the current kernel, restart the kernel once. Then, in the
231
+ first plotting cell:
232
+
233
+ ```python
234
+ %matplotlib widget
235
+
236
+ from tensor_network_viz import PlotConfig, show_tensor_network
237
+
238
+ fig, ax = show_tensor_network(
239
+ network,
240
+ config=PlotConfig(show_tensor_labels=True, hover_labels=True),
241
+ )
242
+ ```
243
+
244
+ See [Installation](docs/installation.md) and [User Guide](docs/guide.md) for details.
245
+
246
+ ## Documentation
247
+
248
+ - [Installation](docs/installation.md): virtual environments, optional extras, Jupyter, and local
249
+ editable installs.
250
+ - [API Reference](docs/api.md): public functions, configuration objects, snapshots, exceptions, and
251
+ logging.
252
+ - [User Guide](docs/guide.md): workflows, notebooks, exports, layouts, tensor inspection,
253
+ comparisons, snapshots, and performance tips.
254
+ - [Layout Algorithms](docs/algorithms.md): node placement and free-edge direction rules in 2D and
255
+ 3D.
256
+ - [Backend Examples](docs/backends.md): copy-paste examples for TensorKrowch, TensorNetwork, Quimb,
257
+ TeNPy, and `einsum`.
258
+ - [Troubleshooting](docs/troubleshooting.md): common install, Jupyter, Matplotlib, backend, and data
259
+ issues.
260
+ - [Repository Examples](examples/README.md): command-line demo launcher and example catalog.
261
+ - [Demo Commands](commands.md): copy-paste commands for every repository demo.
262
+
263
+ ## Demo Gallery
264
+
265
+ The repository examples are organized around the same launcher:
266
+
267
+ ```bash
268
+ python examples/run_demo.py <group> <demo>
269
+ ```
270
+
271
+ The gallery includes backend demos for TensorKrowch, TensorNetwork, Quimb, TeNPy, and `einsum`,
272
+ plus three focused groups:
273
+
274
+ - `themes overview`: compares the `PlotConfig` visual presets for tensor-network figures.
275
+ - `themes tensor_elements`: compares the `TensorElementsConfig` presets for `show_tensor_elements(...)`
276
+ and the linked tensor inspector.
277
+ - `placements`: shows object, list, 2D grid, 3D grid, manual positions, manual schemes, and named
278
+ index inputs.
279
+ - `geometry`: renders larger irregular, incomplete, triangular, pyramidal, circular, and
280
+ disconnected networks.
281
+
282
+ There is also a dedicated translation demo:
283
+
284
+ ```bash
285
+ python examples/translate_demo.py --source-engine tensornetwork --target-engine quimb --example mps
286
+ ```
287
+
288
+ It generates Python code for the translated tensor network and can render the original and
289
+ translated versions side by side for comparison.
290
+
291
+ For batch checks, use:
292
+
293
+ ```bash
294
+ python examples/run_all_examples.py --group engines --views 2d --list
295
+ python examples/run_all_examples.py --group all --views 2d --output-dir .tmp/examples
296
+ ```
297
+
298
+ ## Project Links
299
+
300
+ - [License](LICENSE) (MIT)
301
+ - [Third-party licenses](THIRD_PARTY_LICENSES.md)
302
+ - [Changelog](CHANGELOG.md)
303
+ - [Contributing](CONTRIBUTING.md)
304
+ - [Code of Conduct](CODE_OF_CONDUCT.md)
305
+ - [Citation](CITATION.cff)
306
+ - [Issues](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/issues)
307
+ - [Repository](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization)