From 241593b9d37b885ffb334bcced0a5dc4d334e9ea Mon Sep 17 00:00:00 2001 From: yzhuang-els Date: Mon, 11 May 2026 15:24:25 +0200 Subject: [PATCH 1/6] fix: prevent infinite loop in Leiden refinement on symmetric subgraphs --- sknetwork/clustering/leiden.py | 2 +- sknetwork/clustering/leiden_core.pyx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sknetwork/clustering/leiden.py b/sknetwork/clustering/leiden.py index 36b918f0..8d8e8412 100644 --- a/sknetwork/clustering/leiden.py +++ b/sknetwork/clustering/leiden.py @@ -163,7 +163,7 @@ def _optimize_refine(self, labels, adjacency, out_weights, in_weights): labels_refined = np.arange(len(labels)).astype(np.int32) return optimize_refine_core(labels, labels_refined, indices, indptr, data, out_weights, in_weights, out_cluster_weights, in_cluster_weights, cluster_weights, self_loops, - self.resolution) + self.resolution, self.tol_optimization) @staticmethod def _aggregate_refine(labels, labels_refined, adjacency, out_weights, in_weights): diff --git a/sknetwork/clustering/leiden_core.pyx b/sknetwork/clustering/leiden_core.pyx index e8814569..03d87fe0 100644 --- a/sknetwork/clustering/leiden_core.pyx +++ b/sknetwork/clustering/leiden_core.pyx @@ -13,7 +13,8 @@ ctypedef fused int_or_long: @cython.wraparound(False) def optimize_refine_core(int_or_long[:] labels, int_or_long[:] labels_refined, int_or_long[:] indices, int_or_long[:] indptr, float[:] data, float[:] out_weights, float[:] in_weights, float[:] out_cluster_weights, - float[:] in_cluster_weights, float[:] cluster_weights, float[:] self_loops, float resolution): # pragma: no cover + float[:] in_cluster_weights, float[:] cluster_weights, float[:] self_loops, float resolution, + float tol_optimization): # pragma: no cover """Refine clusters while maximizing modularity. Parameters @@ -42,6 +43,8 @@ def optimize_refine_core(int_or_long[:] labels, int_or_long[:] labels_refined, i Weights of self loops. resolution : Resolution parameter (positive). + tol_optimization : + Minimum increase in modularity to enter a new optimization pass. Returns ------- @@ -102,7 +105,7 @@ def optimize_refine_core(int_or_long[:] labels, int_or_long[:] labels_refined, i delta_local -= resolution * out_weight * in_cluster_weights[label_target] delta_local -= resolution * in_weight * out_cluster_weights[label_target] delta_local -= delta - if delta_local > 0: + if delta_local > tol_optimization: label_target_set.insert(label_target) cluster_weights[label_target] = 0 From 479530b0262814d3ea18ba46fd682cb06ef74d2d Mon Sep 17 00:00:00 2001 From: yzhuang-els Date: Wed, 27 May 2026 09:50:19 +0200 Subject: [PATCH 2/6] install openblas --- .github/workflows/wheels_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels_build.yml b/.github/workflows/wheels_build.yml index 486fb489..a1adc6c1 100644 --- a/.github/workflows/wheels_build.yml +++ b/.github/workflows/wheels_build.yml @@ -23,6 +23,7 @@ jobs: CIBW_SKIP: cp*-musllinux* *-win32 CIBW_ARCHS_MACOS: x86_64 arm64 CIBW_BUILD_VERBOSITY: 3 + CIBW_BEFORE_ALL_LINUX: "yum install -y openblas-devel || apt-get install -y libopenblas-dev" CIBW_BEFORE_BUILD: "pip install -r requirements_dev.txt && pip install ." CIBW_BUILD: cp310-* cp311-* cp312-* cp313-* cp314-* From 6591409b9ec75ab8546d677c9ade3f695d86de55 Mon Sep 17 00:00:00 2001 From: yzhuang-els Date: Thu, 28 May 2026 12:09:41 +0200 Subject: [PATCH 3/6] ci: replace deprecated setup.py develop with pip install -e . --- .github/workflows/ci_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_checks.yml b/.github/workflows/ci_checks.yml index c8094b42..4baaf268 100644 --- a/.github/workflows/ci_checks.yml +++ b/.github/workflows/ci_checks.yml @@ -26,7 +26,7 @@ jobs: python -m pip install --upgrade pip python -m pip install flake8 python -m pip install -r requirements_dev.txt - python setup.py develop + pip install -e . - name: Test with pytest run: | py.test --doctest-modules --cov-report=xml --cov=sknetwork From 2548c19200e8f6f5fe2790e52e30522fdd04af40 Mon Sep 17 00:00:00 2001 From: yzhuang-els Date: Thu, 28 May 2026 13:36:58 +0200 Subject: [PATCH 4/6] ci: enable epel repository for centos for openblas-devel --- .github/workflows/wheels_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels_build.yml b/.github/workflows/wheels_build.yml index a1adc6c1..2157c181 100644 --- a/.github/workflows/wheels_build.yml +++ b/.github/workflows/wheels_build.yml @@ -23,7 +23,7 @@ jobs: CIBW_SKIP: cp*-musllinux* *-win32 CIBW_ARCHS_MACOS: x86_64 arm64 CIBW_BUILD_VERBOSITY: 3 - CIBW_BEFORE_ALL_LINUX: "yum install -y openblas-devel || apt-get install -y libopenblas-dev" + CIBW_BEFORE_ALL_LINUX: "yum install -y epel-release && yum install -y openblas-devel" CIBW_BEFORE_BUILD: "pip install -r requirements_dev.txt && pip install ." CIBW_BUILD: cp310-* cp311-* cp312-* cp313-* cp314-* From 11c17d8f1c18231b0db11164a7037566c5db57e3 Mon Sep 17 00:00:00 2001 From: yzhuang-els Date: Thu, 28 May 2026 14:53:28 +0200 Subject: [PATCH 5/6] fix(ci): use newer manylinux image with pre-built wheel for scipy --- .github/workflows/wheels_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels_build.yml b/.github/workflows/wheels_build.yml index 2157c181..e8dbd804 100644 --- a/.github/workflows/wheels_build.yml +++ b/.github/workflows/wheels_build.yml @@ -23,7 +23,7 @@ jobs: CIBW_SKIP: cp*-musllinux* *-win32 CIBW_ARCHS_MACOS: x86_64 arm64 CIBW_BUILD_VERBOSITY: 3 - CIBW_BEFORE_ALL_LINUX: "yum install -y epel-release && yum install -y openblas-devel" + CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 CIBW_BEFORE_BUILD: "pip install -r requirements_dev.txt && pip install ." CIBW_BUILD: cp310-* cp311-* cp312-* cp313-* cp314-* From ad67c4b37bddc23190919da356b1250f110f1d0a Mon Sep 17 00:00:00 2001 From: yzhuang-els Date: Thu, 28 May 2026 15:48:32 +0200 Subject: [PATCH 6/6] ci: upgrade manylinux image to 2_28 for x86_64 as well --- .github/workflows/wheels_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels_build.yml b/.github/workflows/wheels_build.yml index e8dbd804..8230b784 100644 --- a/.github/workflows/wheels_build.yml +++ b/.github/workflows/wheels_build.yml @@ -24,6 +24,7 @@ jobs: CIBW_ARCHS_MACOS: x86_64 arm64 CIBW_BUILD_VERBOSITY: 3 CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BEFORE_BUILD: "pip install -r requirements_dev.txt && pip install ." CIBW_BUILD: cp310-* cp311-* cp312-* cp313-* cp314-*