tensor-network-visualization 1.4.2__tar.gz → 1.5.1__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.
Files changed (139) hide show
  1. tensor_network_visualization-1.5.1/PKG-INFO +466 -0
  2. tensor_network_visualization-1.5.1/README.md +415 -0
  3. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/pyproject.toml +20 -7
  4. tensor_network_visualization-1.5.1/src/tensor_network_visualization.egg-info/PKG-INFO +466 -0
  5. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_visualization.egg-info/SOURCES.txt +32 -1
  6. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_visualization.egg-info/requires.txt +1 -1
  7. tensor_network_visualization-1.5.1/src/tensor_network_viz/__init__.py +105 -0
  8. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/axis_directions.py +10 -0
  9. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/draw/contraction_edges.py +149 -0
  10. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/contraction_scheme.py +87 -58
  11. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/draw/dangling_self_edges.py +445 -0
  12. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/draw/edge_labels.py +139 -0
  13. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/draw/edge_orchestration.py +214 -0
  14. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/draw/edges.py +16 -0
  15. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/draw/graph_pipeline.py +335 -0
  16. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/hover.py +412 -250
  17. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/plotter.py +21 -2
  18. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/draw/render_prep.py +408 -0
  19. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/draw/scene_state.py +51 -0
  20. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/tensors.py +199 -198
  21. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/viewport_geometry.py +700 -693
  22. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/graph.py +13 -0
  23. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/layout/body.py +150 -0
  24. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/layout/direction_common.py +477 -0
  25. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/layout/free_directions_2d.py +493 -0
  26. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/layout/free_directions_3d.py +250 -0
  27. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/layout/geometry.py +382 -0
  28. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/layout/parameters.py +12 -0
  29. tensor_network_visualization-1.5.1/src/tensor_network_viz/_core/layout/positions.py +802 -0
  30. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/layout_structure.py +510 -506
  31. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/renderer.py +495 -444
  32. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_registry.py +8 -4
  33. tensor_network_visualization-1.5.1/src/tensor_network_viz/_tensor_elements_data.py +474 -0
  34. tensor_network_visualization-1.5.1/src/tensor_network_viz/_tensor_elements_payloads.py +573 -0
  35. tensor_network_visualization-1.5.1/src/tensor_network_viz/_tensor_elements_support.py +47 -0
  36. tensor_network_visualization-1.5.1/src/tensor_network_viz/_typing.py +25 -0
  37. tensor_network_visualization-1.5.1/src/tensor_network_viz/_ui_utils.py +33 -0
  38. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/config.py +29 -18
  39. tensor_network_visualization-1.5.1/src/tensor_network_viz/contraction_viewer.py +938 -0
  40. tensor_network_visualization-1.5.1/src/tensor_network_viz/einsum_module/__init__.py +46 -0
  41. tensor_network_visualization-1.5.1/src/tensor_network_viz/einsum_module/contraction_cost.py +79 -0
  42. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/einsum_module/graph.py +11 -0
  43. tensor_network_visualization-1.5.1/src/tensor_network_viz/interactive_viewer.py +572 -0
  44. tensor_network_visualization-1.5.1/src/tensor_network_viz/quimb/__init__.py +32 -0
  45. tensor_network_visualization-1.5.1/src/tensor_network_viz/tenpy/__init__.py +37 -0
  46. tensor_network_visualization-1.5.1/src/tensor_network_viz/tensor_elements.py +453 -0
  47. tensor_network_visualization-1.5.1/src/tensor_network_viz/tensor_elements_config.py +34 -0
  48. tensor_network_visualization-1.5.1/src/tensor_network_viz/tensorkrowch/__init__.py +32 -0
  49. tensor_network_visualization-1.5.1/src/tensor_network_viz/tensornetwork/__init__.py +32 -0
  50. tensor_network_visualization-1.5.1/src/tensor_network_viz/viewer.py +219 -0
  51. tensor_network_visualization-1.5.1/tests/test_ci_workflow.py +26 -0
  52. tensor_network_visualization-1.5.1/tests/test_contraction_cost.py +111 -0
  53. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_contraction_groups_once.py +1 -1
  54. tensor_network_visualization-1.5.1/tests/test_contraction_viewer.py +567 -0
  55. tensor_network_visualization-1.5.1/tests/test_demo_cli_scheme.py +210 -0
  56. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_draw_performance.py +1 -1
  57. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_einsum_backend.py +136 -3
  58. tensor_network_visualization-1.5.1/tests/test_engine_detection.py +123 -0
  59. tensor_network_visualization-1.5.1/tests/test_engineering_baseline.py +138 -0
  60. tensor_network_visualization-1.5.1/tests/test_examples.py +342 -0
  61. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_label_draw_metrics_perf.py +1 -1
  62. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_layout_core.py +455 -0
  63. tensor_network_visualization-1.5.1/tests/test_lazy_imports.py +43 -0
  64. tensor_network_visualization-1.5.1/tests/test_packaging_metadata.py +29 -0
  65. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_plotting.py +513 -3
  66. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_public_api.py +219 -183
  67. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_quimb_backend.py +16 -6
  68. tensor_network_visualization-1.5.1/tests/test_render_performance_controls.py +162 -0
  69. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_tenpy_backend.py +10 -3
  70. tensor_network_visualization-1.5.1/tests/test_tensor_elements.py +634 -0
  71. tensor_network_visualization-1.5.1/tests/test_tensor_elements_perf.py +73 -0
  72. tensor_network_visualization-1.5.1/tests/test_verify_script.py +24 -0
  73. tensor_network_visualization-1.4.2/PKG-INFO +0 -418
  74. tensor_network_visualization-1.4.2/README.md +0 -369
  75. tensor_network_visualization-1.4.2/src/tensor_network_visualization.egg-info/PKG-INFO +0 -418
  76. tensor_network_visualization-1.4.2/src/tensor_network_viz/__init__.py +0 -30
  77. tensor_network_visualization-1.4.2/src/tensor_network_viz/_core/draw/edges.py +0 -728
  78. tensor_network_visualization-1.4.2/src/tensor_network_viz/_core/draw/graph_pipeline.py +0 -267
  79. tensor_network_visualization-1.4.2/src/tensor_network_viz/_core/layout/body.py +0 -1251
  80. tensor_network_visualization-1.4.2/src/tensor_network_viz/einsum_module/__init__.py +0 -14
  81. tensor_network_visualization-1.4.2/src/tensor_network_viz/quimb/__init__.py +0 -9
  82. tensor_network_visualization-1.4.2/src/tensor_network_viz/tenpy/__init__.py +0 -12
  83. tensor_network_visualization-1.4.2/src/tensor_network_viz/tensorkrowch/__init__.py +0 -9
  84. tensor_network_visualization-1.4.2/src/tensor_network_viz/tensornetwork/__init__.py +0 -9
  85. tensor_network_visualization-1.4.2/src/tensor_network_viz/viewer.py +0 -93
  86. tensor_network_visualization-1.4.2/tests/test_demo_cli_scheme.py +0 -45
  87. tensor_network_visualization-1.4.2/tests/test_examples.py +0 -455
  88. tensor_network_visualization-1.4.2/tests/test_packaging_metadata.py +0 -17
  89. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/LICENSE +0 -0
  90. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/setup.cfg +0 -0
  91. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_visualization.egg-info/dependency_links.txt +0 -0
  92. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_visualization.egg-info/top_level.txt +0 -0
  93. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/__init__.py +0 -0
  94. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/_draw_common.py +0 -0
  95. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/_label_format.py +0 -0
  96. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/_nodes_edges_common.py +0 -0
  97. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/contractions.py +0 -0
  98. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/curves.py +0 -0
  99. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/__init__.py +0 -0
  100. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/constants.py +0 -0
  101. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/disk_metrics.py +0 -0
  102. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/fonts_and_scale.py +0 -0
  103. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/labels_misc.py +0 -0
  104. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/pick_distance.py +0 -0
  105. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/draw/vectors.py +0 -0
  106. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/graph_cache.py +0 -0
  107. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/graph_utils.py +0 -0
  108. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/layout/__init__.py +0 -0
  109. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/layout/force_directed.py +0 -0
  110. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_core/layout/types.py +0 -0
  111. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/_engine_specs.py +0 -0
  112. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/einsum_module/_backend.py +0 -0
  113. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/einsum_module/_equation.py +0 -0
  114. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/einsum_module/_trace_state.py +0 -0
  115. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/einsum_module/_trace_types.py +0 -0
  116. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/einsum_module/renderer.py +0 -0
  117. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/einsum_module/trace.py +0 -0
  118. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/py.typed +0 -0
  119. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/quimb/graph.py +0 -0
  120. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/quimb/renderer.py +0 -0
  121. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/tenpy/explicit.py +0 -0
  122. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/tenpy/graph.py +0 -0
  123. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/tenpy/renderer.py +0 -0
  124. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/tensorkrowch/graph.py +0 -0
  125. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/tensorkrowch/renderer.py +0 -0
  126. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/tensornetwork/graph.py +0 -0
  127. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/src/tensor_network_viz/tensornetwork/renderer.py +0 -0
  128. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_contraction_scheme.py +0 -0
  129. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_edge_index_label_2d.py +0 -0
  130. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_edge_index_label_3d.py +0 -0
  131. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_einsum_autotrace.py +0 -0
  132. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_examples_structure.py +0 -0
  133. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_graph_cache.py +0 -0
  134. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_integration_einsum.py +0 -0
  135. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_integration_tensorkrowch.py +0 -0
  136. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_integration_tensornetwork.py +0 -0
  137. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_label_format.py +0 -0
  138. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_node_degrees_perf.py +0 -0
  139. {tensor_network_visualization-1.4.2 → tensor_network_visualization-1.5.1}/tests/test_show_tensor_network_throughput.py +0 -0
@@ -0,0 +1,466 @@
1
+ Metadata-Version: 2.4
2
+ Name: tensor-network-visualization
3
+ Version: 1.5.1
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: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Visualization
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: matplotlib>=3.7
23
+ Requires-Dist: networkx>=3.0
24
+ Requires-Dist: numpy
25
+ Provides-Extra: dev
26
+ Requires-Dist: build; extra == "dev"
27
+ Requires-Dist: pytest; extra == "dev"
28
+ Requires-Dist: ruff; extra == "dev"
29
+ Requires-Dist: pyright; extra == "dev"
30
+ Requires-Dist: ipython; extra == "dev"
31
+ Requires-Dist: tensorkrowch; extra == "dev"
32
+ Requires-Dist: tensornetwork; extra == "dev"
33
+ Requires-Dist: quimb; extra == "dev"
34
+ Requires-Dist: physics-tenpy; extra == "dev"
35
+ Provides-Extra: jupyter
36
+ Requires-Dist: ipympl>=0.9.0; extra == "jupyter"
37
+ Requires-Dist: ipywidgets>=8.0; extra == "jupyter"
38
+ Requires-Dist: jupyterlab>=4.0; extra == "jupyter"
39
+ Requires-Dist: notebook>=7.0; extra == "jupyter"
40
+ Provides-Extra: tensorkrowch
41
+ Requires-Dist: tensorkrowch; extra == "tensorkrowch"
42
+ Provides-Extra: tensornetwork
43
+ Requires-Dist: tensornetwork; extra == "tensornetwork"
44
+ Provides-Extra: quimb
45
+ Requires-Dist: quimb; extra == "quimb"
46
+ Provides-Extra: tenpy
47
+ Requires-Dist: physics-tenpy; extra == "tenpy"
48
+ Provides-Extra: einsum
49
+ Requires-Dist: torch; extra == "einsum"
50
+ Dynamic: license-file
51
+
52
+ # Tensor-Network-Visualization
53
+
54
+ [![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)
55
+ [![PyPI version](https://img.shields.io/pypi/v/tensor-network-visualization.svg)](https://pypi.org/project/tensor-network-visualization/)
56
+ [![Python versions](https://img.shields.io/pypi/pyversions/tensor-network-visualization.svg)](https://pypi.org/project/tensor-network-visualization/)
57
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
58
+
59
+ Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced
60
+ PyTorch/NumPy `einsum` tensor networks.
61
+
62
+ **Repository:** [https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization](https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization)
63
+
64
+ ## What This Library Does
65
+
66
+ Tensor-network libraries expose very different Python objects, but this package gives them two
67
+ aligned plotting entry points:
68
+
69
+ ```python
70
+ fig, ax = show_tensor_network(...)
71
+ fig, ax = show_tensor_elements(...)
72
+ ```
73
+
74
+ Internally, the library:
75
+
76
+ 1. normalizes backend objects into one graph model,
77
+ 2. computes a layout,
78
+ 3. draws the graph in 2D or 3D with Matplotlib,
79
+ 4. optionally adds figure controls for view/label/scheme toggles.
80
+
81
+ The goal is to keep the public API small while still being useful for notebooks, papers, debugging,
82
+ and saved figures.
83
+
84
+ ## Install
85
+
86
+ PyPI package name: `tensor-network-visualization`
87
+ Import package: `tensor_network_viz`
88
+
89
+ **Requires Python 3.11 or newer.**
90
+
91
+ ### Base install
92
+
93
+ ```bash
94
+ python -m pip install tensor-network-visualization
95
+ ```
96
+
97
+ Base dependencies are only `numpy`, `matplotlib`, and `networkx`.
98
+
99
+ ### Optional extras
100
+
101
+ | Need | Install |
102
+ | --- | --- |
103
+ | TensorKrowch support | `python -m pip install "tensor-network-visualization[tensorkrowch]"` |
104
+ | TensorNetwork support | `python -m pip install "tensor-network-visualization[tensornetwork]"` |
105
+ | Quimb support | `python -m pip install "tensor-network-visualization[quimb]"` |
106
+ | TeNPy support | `python -m pip install "tensor-network-visualization[tenpy]"` |
107
+ | Traced `einsum(...)` support | `python -m pip install "tensor-network-visualization[einsum]"` |
108
+ | Interactive Jupyter widgets | `python -m pip install "tensor-network-visualization[jupyter]"` |
109
+
110
+ ### Windows and Linux quick start
111
+
112
+ **Windows (PowerShell):**
113
+
114
+ ```powershell
115
+ python -m venv .venv
116
+ .\.venv\Scripts\Activate.ps1
117
+ python -m pip install -U pip
118
+ python -m pip install "tensor-network-visualization[quimb]"
119
+ ```
120
+
121
+ **Linux / macOS:**
122
+
123
+ ```bash
124
+ python3 -m venv .venv
125
+ source .venv/bin/activate
126
+ python -m pip install -U pip
127
+ python -m pip install "tensor-network-visualization[quimb]"
128
+ ```
129
+
130
+ ## The API in One Minute
131
+
132
+ ### `show_tensor_network`
133
+
134
+ Use `show_tensor_network` for figure lifecycle:
135
+
136
+ ```python
137
+ show_tensor_network(
138
+ network,
139
+ *,
140
+ engine=None,
141
+ view=None,
142
+ config=None,
143
+ ax=None,
144
+ show_controls=True,
145
+ show=True,
146
+ )
147
+ ```
148
+
149
+ - `engine`: optional backend override. If omitted, the library auto-detects it.
150
+ - `view`: `"2d"` or `"3d"`. If omitted, it starts in `"2d"`.
151
+ - `config`: all visual behavior lives here.
152
+ - `ax`: render into an existing Matplotlib axis.
153
+ - `show_controls`: if `False`, the figure is saved/rendered without the embedded control panel.
154
+ - `show`: if `False`, nothing is displayed automatically.
155
+
156
+ ### `show_tensor_elements`
157
+
158
+ Use `show_tensor_elements` to inspect tensor values:
159
+
160
+ ```python
161
+ show_tensor_elements(
162
+ data,
163
+ *,
164
+ engine=None,
165
+ config=None,
166
+ ax=None,
167
+ show_controls=True,
168
+ show=True,
169
+ )
170
+ ```
171
+
172
+ When several tensors are present, the figure keeps one tensor active at a time and uses a slider
173
+ to switch between them. The interactive controls are grouped: `basic` (`elements`, `magnitude`,
174
+ `distribution`, `data`), `complex` (`real`, `imag`, `phase`), and `diagnostic` (`sign`,
175
+ `signed_value`).
176
+
177
+ - `data`: single tensor, iterable of tensors, supported backend-native tensor collections, or an
178
+ `EinsumTrace` with live tensor values.
179
+ - `engine`: optional backend override. If omitted, the library auto-detects it.
180
+ - `config`: tensor-inspection behavior lives here.
181
+ - `ax`: render a single tensor into an existing Matplotlib axis.
182
+ - `show_controls`: if `True`, add compact Matplotlib `group + mode` controls and, when needed, a tensor slider.
183
+ - `show`: if `False`, nothing is displayed automatically.
184
+
185
+ ### `PlotConfig`
186
+
187
+ Use `PlotConfig` for visual behavior:
188
+
189
+ ```python
190
+ from tensor_network_viz import PlotConfig
191
+
192
+ config = PlotConfig(
193
+ show_tensor_labels=True,
194
+ show_index_labels=False,
195
+ hover_labels=True,
196
+ show_contraction_scheme=False,
197
+ tensor_label_refinement="auto",
198
+ )
199
+ ```
200
+
201
+ This is where you configure:
202
+
203
+ - labels,
204
+ - hover tooltips,
205
+ - contraction-scheme overlays,
206
+ - styling,
207
+ - layout iterations,
208
+ - custom positions,
209
+ - label-refinement policy,
210
+ - static/export-oriented rendering choices.
211
+
212
+ ### `TensorElementsConfig`
213
+
214
+ Use `TensorElementsConfig` for tensor inspection behavior:
215
+
216
+ ```python
217
+ from tensor_network_viz import TensorElementsConfig
218
+
219
+ config = TensorElementsConfig(
220
+ mode="auto",
221
+ max_matrix_shape=(256, 256),
222
+ histogram_bins=40,
223
+ )
224
+ ```
225
+
226
+ This is where you configure:
227
+
228
+ - the active inspection mode,
229
+ - row/column axis grouping for rank > 2 tensors,
230
+ - heatmap downsampling limits,
231
+ - histogram sampling and bin count.
232
+
233
+ If you want to start in a specific grouped view, pass `mode="real"`, `mode="imag"`,
234
+ `mode="phase"`, `mode="sign"`, or `mode="signed_value"` directly in
235
+ `TensorElementsConfig(...)`.
236
+
237
+ ## Most Common Workflows
238
+
239
+ ### Interactive figure with controls
240
+
241
+ ```python
242
+ from tensor_network_viz import PlotConfig, show_tensor_network
243
+
244
+ fig, ax = show_tensor_network(
245
+ network,
246
+ config=PlotConfig(
247
+ show_tensor_labels=False,
248
+ show_index_labels=False,
249
+ hover_labels=True,
250
+ ),
251
+ )
252
+ ```
253
+
254
+ ### Clean export with no embedded controls
255
+
256
+ ```python
257
+ from tensor_network_viz import PlotConfig, show_tensor_network
258
+
259
+ fig, ax = show_tensor_network(
260
+ network,
261
+ config=PlotConfig(
262
+ show_tensor_labels=True,
263
+ show_index_labels=False,
264
+ ),
265
+ show_controls=False,
266
+ show=False,
267
+ )
268
+ fig.savefig("network.png", bbox_inches="tight")
269
+ ```
270
+
271
+ ### Inspect tensor values
272
+
273
+ ```python
274
+ from tensor_network_viz import TensorElementsConfig, show_tensor_elements
275
+
276
+ fig, ax = show_tensor_elements(
277
+ trace,
278
+ config=TensorElementsConfig(mode="auto"),
279
+ show=False,
280
+ )
281
+ fig.savefig("tensor-elements.png", bbox_inches="tight")
282
+ ```
283
+
284
+ ### Faster render for large graphs
285
+
286
+ ```python
287
+ config = PlotConfig(
288
+ tensor_label_refinement="never",
289
+ layout_iterations=120,
290
+ )
291
+ ```
292
+
293
+ ## Copy-Paste Examples by Backend
294
+
295
+ The library supports auto-detection, but using `engine=...` in examples is often clearer.
296
+
297
+ ### TensorKrowch
298
+
299
+ ```python
300
+ import tensorkrowch as tk
301
+ from tensor_network_viz import PlotConfig, show_tensor_network
302
+
303
+ network = tk.TensorNetwork(name="demo")
304
+ left = tk.Node(shape=(2, 2), axes_names=("a", "b"), name="L", network=network)
305
+ right = tk.Node(shape=(2, 2), axes_names=("b", "c"), name="R", network=network)
306
+ left["b"] ^ right["b"]
307
+
308
+ fig, ax = show_tensor_network(
309
+ network,
310
+ engine="tensorkrowch",
311
+ config=PlotConfig(show_tensor_labels=True),
312
+ )
313
+ ```
314
+
315
+ ### TensorNetwork
316
+
317
+ ```python
318
+ import numpy as np
319
+ import tensornetwork as tn
320
+ from tensor_network_viz import PlotConfig, show_tensor_network
321
+
322
+ left = tn.Node(np.ones((2, 2)), name="L", axis_names=("a", "b"))
323
+ right = tn.Node(np.ones((2, 2)), name="R", axis_names=("b", "c"))
324
+ left["b"] ^ right["b"]
325
+
326
+ fig, ax = show_tensor_network(
327
+ [left, right],
328
+ engine="tensornetwork",
329
+ config=PlotConfig(show_tensor_labels=True),
330
+ )
331
+ ```
332
+
333
+ ### Quimb
334
+
335
+ ```python
336
+ import numpy as np
337
+ import quimb.tensor as qtn
338
+ from tensor_network_viz import PlotConfig, show_tensor_network
339
+
340
+ tensors = [
341
+ qtn.Tensor(np.ones((2, 3)), inds=("i0", "b0"), tags={"T0"}),
342
+ qtn.Tensor(np.ones((3, 2)), inds=("b0", "i1"), tags={"T1"}),
343
+ ]
344
+ network = qtn.TensorNetwork(tensors)
345
+
346
+ fig, ax = show_tensor_network(
347
+ network,
348
+ engine="quimb",
349
+ config=PlotConfig(show_tensor_labels=True),
350
+ )
351
+ ```
352
+
353
+ ### TeNPy
354
+
355
+ ```python
356
+ from tenpy.networks.mps import MPS
357
+ from tenpy.networks.site import SpinHalfSite
358
+ from tensor_network_viz import PlotConfig, show_tensor_network
359
+
360
+ sites = [SpinHalfSite() for _ in range(4)]
361
+ mps = MPS.from_product_state(sites, ["up", "up", "up", "up"], bc="finite")
362
+
363
+ fig, ax = show_tensor_network(
364
+ mps,
365
+ engine="tenpy",
366
+ config=PlotConfig(show_tensor_labels=True),
367
+ show_controls=False,
368
+ show=False,
369
+ )
370
+ ```
371
+
372
+ ### `einsum`
373
+
374
+ ```python
375
+ from tensor_network_viz import PlotConfig, pair_tensor, show_tensor_network
376
+
377
+ trace = [
378
+ pair_tensor("A0", "x0", "r0", "pa,p->a"),
379
+ pair_tensor("r0", "A1", "r1", "a,apb->pb"),
380
+ ]
381
+
382
+ fig, ax = show_tensor_network(
383
+ trace,
384
+ engine="einsum",
385
+ config=PlotConfig(show_contraction_scheme=True),
386
+ )
387
+ ```
388
+
389
+ For fuller backend examples, see [docs/backends.md](docs/backends.md).
390
+
391
+ ## `PlotConfig` Fields You Will Actually Use Often
392
+
393
+ | Field | Why it matters |
394
+ | --- | --- |
395
+ | `show_tensor_labels` | Draw tensor names on nodes. |
396
+ | `show_index_labels` | Draw index labels on bonds and dangling legs. |
397
+ | `hover_labels` | Enable hover tooltips in interactive sessions. |
398
+ | `show_contraction_scheme` | Draw contraction-step regions. |
399
+ | `contraction_playback` | Start with playback controls enabled when controls are shown. |
400
+ | `contraction_scheme_cost_hover` | Show cost tooltip on scheme regions. |
401
+ | `tensor_label_refinement` | `"auto"`, `"always"`, or `"never"` for the expensive label-fit pass. |
402
+ | `layout_iterations` | Force-layout effort. |
403
+ | `positions` | Supply custom node coordinates. |
404
+ | `figsize` | Matplotlib figure size when the figure is created internally. |
405
+
406
+ ## Example Launcher
407
+
408
+ The repository ships a typed demo launcher:
409
+
410
+ ```bash
411
+ python examples/run_demo.py <engine> <example> [options]
412
+ ```
413
+
414
+ Useful examples:
415
+
416
+ ```bash
417
+ python examples/run_demo.py quimb hyper --view 2d
418
+ python examples/run_demo.py tenpy chain --view 2d --save tenpy_chain.png --no-show
419
+ python examples/run_demo.py einsum ellipsis --view 3d --scheme
420
+ ```
421
+
422
+ More details, including an exhaustive copy-paste command list for every CLI example:
423
+ [examples/README.md](examples/README.md)
424
+
425
+ There is also a minimal inspection example that only uses base dependencies:
426
+
427
+ ```bash
428
+ python examples/tensor_elements_demo.py
429
+ ```
430
+
431
+ ## Troubleshooting
432
+
433
+ | Symptom | What to try |
434
+ | --- | --- |
435
+ | Saved figure includes buttons/sliders | Use `show_controls=False`. |
436
+ | Hover tooltips do nothing | Use an interactive Matplotlib backend; hover is not useful for PNG-only runs. |
437
+ | Big graphs are slow | Set `tensor_label_refinement="never"`, reduce `layout_iterations`, or pass `positions`. |
438
+ | `Unsupported tensor network engine` | Install the matching extra or pass the correct backend object. |
439
+ | `show_tensor_elements(...)` fails on TensorKrowch nodes | Materialize the node tensors first; shape-only nodes do not expose element values. |
440
+ | `show_tensor_elements(...)` fails on manual `pair_tensor(...)` lists | Use an `EinsumTrace` with live tensors instead; manual trace steps only describe contractions. |
441
+ | Blank / duplicate Jupyter figure | Assign `fig, ax = show_tensor_network(...)` instead of leaving the tuple as the last line. |
442
+
443
+ ## Documentation Map
444
+
445
+ - [docs/guide.md](docs/guide.md): workflow-oriented guide to the public API.
446
+ - [docs/backends.md](docs/backends.md): copy-paste backend-specific examples.
447
+ - [examples/README.md](examples/README.md): demo launcher and batch-render usage.
448
+ - [examples/tensor_elements_demo.py](examples/tensor_elements_demo.py): minimal tensor inspection
449
+ example.
450
+ - [CHANGELOG.md](CHANGELOG.md): release notes.
451
+
452
+ ## Development
453
+
454
+ Create and use a local virtual environment:
455
+
456
+ ```powershell
457
+ python -m venv .venv
458
+ .\.venv\Scripts\Activate.ps1
459
+ python -m pip install -r requirements.dev.txt
460
+ ```
461
+
462
+ Run the project checks:
463
+
464
+ ```powershell
465
+ .\.venv\Scripts\python scripts\verify.py
466
+ ```