From 4e8f197cb642359e3bdc5a8aab82fc5996a08ba0 Mon Sep 17 00:00:00 2001 From: Alejandro Mata Ali <78550667+DOKOS-TAYOS@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:04:31 +0100 Subject: [PATCH 1/4] chore(deps): refresh runtime and dev versions for 2.0.4 --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.md | 6 ++++- pyproject.toml | 22 ++++++++--------- requirements.dev.txt | 20 ++++++++-------- .../_core/layout_structure.py | 24 ++++++++++++++++++- .../_tensor_elements_data.py | 11 ++++----- tests/test_ci_workflow.py | 8 +++---- tests/test_engineering_baseline.py | 18 +++++++------- tests/test_packaging_metadata.py | 2 +- 9 files changed, 70 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3768e9a..707c9f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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.7 numpy==2.5.5 pytest==9.2.0 quimb==1.14.0 - name: Run headless example run: python scripts/verify.py smoke @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b1a634..c4e066a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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, and NumPy; 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 diff --git a/pyproject.toml b/pyproject.toml index bc3aa5e..96db3f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -13,9 +13,9 @@ 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.7", + "numpy>=2.5.5", ] classifiers = [ "Development Status :: 5 - Production/Stable", @@ -40,15 +40,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", diff --git a/requirements.dev.txt b/requirements.dev.txt index 27ee2eb..7536bfd 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,18 +1,18 @@ -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.7 +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 diff --git a/src/tensor_network_viz/_core/layout_structure.py b/src/tensor_network_viz/_core/layout_structure.py index fbb2ad9..19148a2 100644 --- a/src/tensor_network_viz/_core/layout_structure.py +++ b/src/tensor_network_viz/_core/layout_structure.py @@ -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 diff --git a/src/tensor_network_viz/_tensor_elements_data.py b/src/tensor_network_viz/_tensor_elements_data.py index cae25d2..af8cbbd 100644 --- a/src/tensor_network_viz/_tensor_elements_data.py +++ b/src/tensor_network_viz/_tensor_elements_data.py @@ -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] diff --git a/tests/test_ci_workflow.py b/tests/test_ci_workflow.py index a6dcf68..dead9ad 100644 --- a/tests/test_ci_workflow.py +++ b/tests/test_ci_workflow.py @@ -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", - "networkx==3.6.1", - "numpy==2.4.6", - "pytest==9.1.1", + "matplotlib==3.11.2", + "networkx==3.7", + "numpy==2.5.5", + "pytest==9.2.0", "quimb==1.14.0", ): assert requirement in minimal_install diff --git a/tests/test_engineering_baseline.py b/tests/test_engineering_baseline.py index e2eae32..1da17d8 100644 --- a/tests/test_engineering_baseline.py +++ b/tests/test_engineering_baseline.py @@ -144,19 +144,19 @@ 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", - "networkx==3.6.1", - "numpy==2.4.6", + "ipython==9.18.1", + "matplotlib==3.11.2", + "networkx==3.7", + "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", diff --git a/tests/test_packaging_metadata.py b/tests/test_packaging_metadata.py index fa36ea2..e983f5a 100644 --- a/tests/test_packaging_metadata.py +++ b/tests/test_packaging_metadata.py @@ -20,7 +20,7 @@ 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.7", "numpy>=2.5.5"] def test_project_uses_spdx_license_metadata() -> None: From 9ce7c304d7e0623c127a6a75e03f07d0110bb31b Mon Sep 17 00:00:00 2001 From: Alejandro Mata Ali <78550667+DOKOS-TAYOS@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:09:40 +0100 Subject: [PATCH 2/4] Keep Python 3.11 support with compatible NetworkX pins --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 2 +- pyproject.toml | 3 ++- requirements.dev.txt | 3 ++- tests/test_ci_workflow.py | 2 +- tests/test_engineering_baseline.py | 1 + tests/test_packaging_metadata.py | 7 ++++++- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 707c9f4..e1adbe6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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.2 networkx==3.7 numpy==2.5.5 pytest==9.2.0 quimb==1.14.0 + python -m pip install matplotlib==3.11.2 networkx==3.6.1 numpy==2.5.5 pytest==9.2.0 quimb==1.14.0 - name: Run headless example run: python scripts/verify.py smoke diff --git a/CHANGELOG.md b/CHANGELOG.md index c4e066a..51350ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- **Dependency refresh:** Raised runtime minimums for Matplotlib, NetworkX, and NumPy; refreshed development and CI pins while retaining the TensorKrowch, TensorNetwork, Quimb, and TeNPy version requirements. +- **Dependency refresh:** Raised runtime minimums for Matplotlib, NetworkX (3.6.1 on Python 3.11, 3.7 on Python 3.12+), and NumPy; 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. diff --git a/pyproject.toml b/pyproject.toml index 96db3f1..325211f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,8 @@ requires-python = ">=3.11" keywords = ["tensor-network", "visualization", "pytorch", "numpy", "tensorkrowch", "tensornetwork", "quimb", "tenpy", "einsum", "quantum-inspired", "matplotlib"] dependencies = [ "matplotlib>=3.11.2", - "networkx>=3.7", + "networkx>=3.6.1; python_version < '3.12'", + "networkx>=3.7; python_version >= '3.12'", "numpy>=2.5.5", ] classifiers = [ diff --git a/requirements.dev.txt b/requirements.dev.txt index 7536bfd..ad2315a 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -4,7 +4,8 @@ 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.7 +networkx==3.6.1 ; python_version < "3.12" +networkx==3.7 ; python_version >= "3.12" numpy==2.5.5 pip-audit==2.10.1 physics-tenpy==1.1.0 diff --git a/tests/test_ci_workflow.py b/tests/test_ci_workflow.py index dead9ad..0898e06 100644 --- a/tests/test_ci_workflow.py +++ b/tests/test_ci_workflow.py @@ -211,7 +211,7 @@ 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.2", - "networkx==3.7", + "networkx==3.6.1", "numpy==2.5.5", "pytest==9.2.0", "quimb==1.14.0", diff --git a/tests/test_engineering_baseline.py b/tests/test_engineering_baseline.py index 1da17d8..17304aa 100644 --- a/tests/test_engineering_baseline.py +++ b/tests/test_engineering_baseline.py @@ -148,6 +148,7 @@ def test_dev_requirements_pin_verification_tools_and_use_editable_install() -> N "bandit==1.9.4", "ipython==9.18.1", "matplotlib==3.11.2", + "networkx==3.6.1", "networkx==3.7", "numpy==2.5.5", "pip-audit==2.10.1", diff --git a/tests/test_packaging_metadata.py b/tests/test_packaging_metadata.py index e983f5a..3397c17 100644 --- a/tests/test_packaging_metadata.py +++ b/tests/test_packaging_metadata.py @@ -20,7 +20,12 @@ def test_base_dependencies_are_declared_explicitly() -> None: dependencies = pyproject["project"]["dependencies"] - assert dependencies == ["matplotlib>=3.11.2", "networkx>=3.7", "numpy>=2.5.5"] + assert dependencies == [ + "matplotlib>=3.11.2", + "networkx>=3.6.1; python_version < '3.12'", + "networkx>=3.7; python_version >= '3.12'", + "numpy>=2.5.5", + ] def test_project_uses_spdx_license_metadata() -> None: From a7ee3a3e80245529923c7227f3617990d4ce6398 Mon Sep 17 00:00:00 2001 From: Alejandro Mata Ali <78550667+DOKOS-TAYOS@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:12:17 +0100 Subject: [PATCH 3/4] Preserve Python 3.11 support with conditional NumPy pins --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 2 +- pyproject.toml | 3 ++- requirements.dev.txt | 3 ++- tests/test_ci_workflow.py | 2 +- tests/test_engineering_baseline.py | 1 + tests/test_packaging_metadata.py | 3 ++- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1adbe6..93b4485 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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.2 networkx==3.6.1 numpy==2.5.5 pytest==9.2.0 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 51350ed..bb8b892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ 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; refreshed development and CI pins while retaining the TensorKrowch, TensorNetwork, Quimb, and TeNPy version requirements. +- **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. diff --git a/pyproject.toml b/pyproject.toml index 325211f..3f872c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,8 @@ dependencies = [ "matplotlib>=3.11.2", "networkx>=3.6.1; python_version < '3.12'", "networkx>=3.7; python_version >= '3.12'", - "numpy>=2.5.5", + "numpy>=2.4.5; python_version < '3.12'", + "numpy>=2.5.5; python_version >= '3.12'", ] classifiers = [ "Development Status :: 5 - Production/Stable", diff --git a/requirements.dev.txt b/requirements.dev.txt index ad2315a..1907ba6 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -6,7 +6,8 @@ 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.5.5 +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.414 diff --git a/tests/test_ci_workflow.py b/tests/test_ci_workflow.py index 0898e06..b912560 100644 --- a/tests/test_ci_workflow.py +++ b/tests/test_ci_workflow.py @@ -212,7 +212,7 @@ def test_ci_workflow_keeps_minimal_and_packaging_smoke_guards() -> None: for requirement in ( "matplotlib==3.11.2", "networkx==3.6.1", - "numpy==2.5.5", + "numpy==2.4.5", "pytest==9.2.0", "quimb==1.14.0", ): diff --git a/tests/test_engineering_baseline.py b/tests/test_engineering_baseline.py index 17304aa..5abc16c 100644 --- a/tests/test_engineering_baseline.py +++ b/tests/test_engineering_baseline.py @@ -150,6 +150,7 @@ def test_dev_requirements_pin_verification_tools_and_use_editable_install() -> N "matplotlib==3.11.2", "networkx==3.6.1", "networkx==3.7", + "numpy==2.4.5", "numpy==2.5.5", "pip-audit==2.10.1", "physics-tenpy==1.1.0", diff --git a/tests/test_packaging_metadata.py b/tests/test_packaging_metadata.py index 3397c17..b441eca 100644 --- a/tests/test_packaging_metadata.py +++ b/tests/test_packaging_metadata.py @@ -24,7 +24,8 @@ def test_base_dependencies_are_declared_explicitly() -> None: "matplotlib>=3.11.2", "networkx>=3.6.1; python_version < '3.12'", "networkx>=3.7; python_version >= '3.12'", - "numpy>=2.5.5", + "numpy>=2.4.5; python_version < '3.12'", + "numpy>=2.5.5; python_version >= '3.12'", ] From eaeafad41bda97ca1a0921cda5d22f078fc4e118 Mon Sep 17 00:00:00 2001 From: Alejandro Mata Ali <78550667+DOKOS-TAYOS@users.noreply.github.com> Date: Mon, 16 Nov 2026 21:21:14 +0100 Subject: [PATCH 4/4] Fix Matplotlib pyplot monkeypatch isolation in notebook tests --- tests/test_plotting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_plotting.py b/tests/test_plotting.py index d68a2b8..c3094b9 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -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", @@ -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)