Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install minimal pinned dependencies
run: |
python -m pip install -e . --no-deps
python -m pip install matplotlib==3.11.1 networkx==3.6.1 numpy==2.4.6 pytest==9.1.1 quimb==1.14.0
python -m pip install matplotlib==3.11.2 networkx==3.6.1 numpy==2.4.5 pytest==9.2.0 quimb==1.14.0

- name: Run headless example
run: python scripts/verify.py smoke
Expand All @@ -55,7 +55,7 @@ jobs:
cache: "pip"

- name: Install build tool
run: python -m pip install build==1.5.0 twine==6.2.0 setuptools==83.0.0
run: python -m pip install build==1.6.1 twine==7.0.0 setuptools==84.2.1

- name: Build package artifacts
run: python scripts/verify.py package
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **Dependency refresh:** Raised runtime minimums for Matplotlib, NetworkX (3.6.1 on Python 3.11, 3.7 on Python 3.12+), and NumPy (2.4.5 on Python 3.11, 2.5.5 on Python 3.12+); refreshed development and CI pins while retaining the TensorKrowch, TensorNetwork, Quimb, and TeNPy version requirements.
- **Package version:** Prepared `2.0.4` for the updated runtime dependency baseline.
- **PyTorch compatibility:** Removed the obsolete `setuptools<82` maintenance assumption after verifying that the current PyTorch package permits newer setuptools versions.
- **Grid layout stability:** Canonicalized grid reflections across NetworkX isomorphism versions to preserve boundary-vector orientation.
- **Typing:** Kept top-k index values explicitly typed as integers under the newer NumPy and Pyright packages.
- **CI maintenance:** Updated `actions/checkout` from `v6` to `v7` in the GitHub Actions workflow.
- **Dependabot policy:** Ignore `setuptools` updates to `>=82` for the `pip` ecosystem until the pinned PyTorch dependency no longer requires `setuptools<82`.

## [2.0.3] — 2026-05-17

Expand Down
24 changes: 13 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "tensor-network-visualization"
version = "2.0.3"
version = "2.0.4"
description = "Minimal Matplotlib visualizations for TensorKrowch, TensorNetwork, Quimb, TeNPy, and traced PyTorch/NumPy einsum tensor networks."
authors = [{ name = "Alejandro Mata Ali" }]
readme = "README.md"
Expand All @@ -13,9 +13,11 @@ license-files = ["LICENSE"]
requires-python = ">=3.11"
keywords = ["tensor-network", "visualization", "pytorch", "numpy", "tensorkrowch", "tensornetwork", "quimb", "tenpy", "einsum", "quantum-inspired", "matplotlib"]
dependencies = [
"matplotlib>=3.7",
"networkx>=3.0",
"numpy>=2.0",
"matplotlib>=3.11.2",
"networkx>=3.6.1; python_version < '3.12'",
"networkx>=3.7; python_version >= '3.12'",
"numpy>=2.4.5; python_version < '3.12'",
"numpy>=2.5.5; python_version >= '3.12'",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand All @@ -40,15 +42,15 @@ Issues = "https://github.com/DOKOS-TAYOS/Tensor-Network-Visualization/issues"
[project.optional-dependencies]
dev = [
"bandit>=1.9.4",
"build>=1.5.0",
"pytest>=9.1.1",
"ruff>=0.15.22",
"setuptools>=83.0.0",
"pyright>=1.1.411",
"build>=1.6.1",
"pytest>=9.2.0",
"ruff>=0.17.5",
"setuptools>=84.2.1",
"pyright>=1.1.414",
"pip-audit>=2.10.1",

"twine>=6.0.0",
"ipython>=8.10.0",
"twine>=7.0.0",
"ipython>=9.18.1",
"tensorkrowch>=1.1",
"tensornetwork>=0.4",
"quimb>=1.7",
Expand Down
22 changes: 12 additions & 10 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
-e .
bandit==1.9.4
build==1.5.0
ipython==9.15.0 ; python_version >= "3.12"
ipython==9.15.0 ; python_version < "3.12"
matplotlib==3.11.1
networkx==3.6.1
numpy==2.4.6
build==1.6.1
ipython==9.18.1 ; python_version >= "3.12"
ipython==9.18.1 ; python_version < "3.12"
matplotlib==3.11.2
networkx==3.6.1 ; python_version < "3.12"
networkx==3.7 ; python_version >= "3.12"
numpy==2.4.5 ; python_version < "3.12"
numpy==2.5.5 ; python_version >= "3.12"
pip-audit==2.10.1
physics-tenpy==1.1.0
pyright==1.1.411
pytest==9.1.1
pyright==1.1.414
pytest==9.2.0
quimb==1.14.0
ruff==0.15.22
setuptools==84.1.0
ruff==0.17.5
setuptools==84.2.1
tensorkrowch==1.1.6
tensornetwork==0.4.6
twine==7.0.0
24 changes: 23 additions & 1 deletion src/tensor_network_viz/_core/layout_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,29 @@ def _detect_grid(nx_graph: nx.Graph) -> dict[int, tuple[int, int]] | None:
mapping = nx.vf2pp_isomorphism(nx_graph, grid_graph)
if mapping is None:
continue
return {node_id: (grid_col, grid_row) for node_id, (grid_row, grid_col) in mapping.items()}
coordinates = {
node_id: (grid_col, grid_row) for node_id, (grid_row, grid_col) in mapping.items()
}
# Grid isomorphisms have reflection symmetries. NetworkX may choose a
# different representative across releases, so orient each axis using
# the node IDs instead of relying on the isomorphism iteration order.
for axis in (0, 1):
low = min(value[axis] for value in coordinates.values())
high = max(value[axis] for value in coordinates.values())
if low == high:
continue
low_id = min(node_id for node_id, value in coordinates.items() if value[axis] == low)
high_id = min(node_id for node_id, value in coordinates.items() if value[axis] == high)
if low_id > high_id:
coordinates = {
node_id: (
(low + high - value[0], value[1])
if axis == 0
else (value[0], low + high - value[1])
)
for node_id, value in coordinates.items()
}
return coordinates
return None


Expand Down
11 changes: 5 additions & 6 deletions src/tensor_network_viz/_tensor_elements_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,12 @@ def _topk_flat_indices(magnitudes: NumericArray, *, count: int) -> NumericArray:
partitioned = np.argpartition(normalized, partition_index)
threshold = float(normalized[int(partitioned[partition_index])])
higher = np.flatnonzero(normalized > threshold)
higher_ranked = np.asarray(
sorted(
(int(flat_index) for flat_index in higher),
key=lambda flat_index: _topk_sort_key(float(normalized[flat_index]), flat_index),
),
dtype=np.intp,
higher_indices: list[int] = [int(flat_index) for flat_index in higher]
higher_sorted = sorted(
higher_indices,
key=lambda flat_index: _topk_sort_key(float(normalized[flat_index]), flat_index),
)
higher_ranked = np.asarray(higher_sorted, dtype=np.intp)
remaining = requested_count - int(higher_ranked.size)
if remaining <= 0:
return higher_ranked[:requested_count]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_ci_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ def test_ci_workflow_keeps_minimal_and_packaging_smoke_guards() -> None:

assert "python -m pip install -e . --no-deps" in minimal_install
for requirement in (
"matplotlib==3.11.1",
"matplotlib==3.11.2",
"networkx==3.6.1",
"numpy==2.4.6",
"pytest==9.1.1",
"numpy==2.4.5",
"pytest==9.2.0",
"quimb==1.14.0",
):
assert requirement in minimal_install
Expand Down
18 changes: 10 additions & 8 deletions tests/test_engineering_baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,21 @@ def test_dev_requirements_pin_verification_tools_and_use_editable_install() -> N

assert "-e ." in lines
assert {
"build==1.5.0",
"build==1.6.1",
"bandit==1.9.4",
"ipython==9.15.0",
"matplotlib==3.11.1",
"ipython==9.18.1",
"matplotlib==3.11.2",
"networkx==3.6.1",
"numpy==2.4.6",
"networkx==3.7",
"numpy==2.4.5",
"numpy==2.5.5",
"pip-audit==2.10.1",
"physics-tenpy==1.1.0",
"pyright==1.1.411",
"pytest==9.1.1",
"pyright==1.1.414",
"pytest==9.2.0",
"quimb==1.14.0",
"ruff==0.15.22",
"setuptools==84.1.0",
"ruff==0.17.5",
"setuptools==84.2.1",
"tensorkrowch==1.1.6",
"tensornetwork==0.4.6",
"twine==7.0.0",
Expand Down
8 changes: 7 additions & 1 deletion tests/test_packaging_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ def test_base_dependencies_are_declared_explicitly() -> None:

dependencies = pyproject["project"]["dependencies"]

assert dependencies == ["matplotlib>=3.7", "networkx>=3.0", "numpy>=2.0"]
assert dependencies == [
"matplotlib>=3.11.2",
"networkx>=3.6.1; python_version < '3.12'",
"networkx>=3.7; python_version >= '3.12'",
"numpy>=2.4.5; python_version < '3.12'",
"numpy>=2.5.5; python_version >= '3.12'",
]


def test_project_uses_spdx_license_metadata() -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3553,7 +3553,7 @@ def test_show_tensor_network_displays_selected_renderer(monkeypatch: pytest.Monk
def fake_show() -> None:
shown["value"] = True

monkeypatch.setattr(viewer_module.plt, "show", fake_show)
monkeypatch.setattr(plt, "show", fake_show)
fig, ax = show_tensor_network(
DummyNetwork(nodes=[node]),
engine="tensorkrowch",
Expand Down Expand Up @@ -3625,8 +3625,8 @@ def _fake_show() -> None:

monkeypatch.setattr("IPython.core.getipython.get_ipython", _fake_get_ipython)
monkeypatch.setattr("IPython.display.display", _fake_display)
monkeypatch.setattr(viewer_module.plt, "show", _fake_show)
monkeypatch.setattr(viewer_module.plt, "get_backend", lambda: backend_name)
monkeypatch.setattr(plt, "show", _fake_show)
monkeypatch.setattr(plt, "get_backend", lambda: backend_name)

viewer_module._show_figure(fig)

Expand Down
Loading