From e2c055591b4d3cad6922e8d8f267f25cffc8eef9 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 21 May 2025 10:01:54 +0200 Subject: [PATCH 1/4] fixes numba warning --- src/squidpy/gr/_ligrec.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/squidpy/gr/_ligrec.py b/src/squidpy/gr/_ligrec.py index d54ce91f..defdeac6 100644 --- a/src/squidpy/gr/_ligrec.py +++ b/src/squidpy/gr/_ligrec.py @@ -93,6 +93,9 @@ def _create_template(n_cls: int, return_means: bool = False, parallel: bool = Tr g{i} = np.zeros((data.shape[1],), dtype=np.float64); s{i} = 0""" for i in rng ) + init += """ + error = False + """ loop_body = """ if cl == 0: @@ -110,7 +113,7 @@ def _create_template(n_cls: int, return_means: bool = False, parallel: bool = Tr cl = clustering[row] {loop_body} else: - assert False, "Unhandled case." + error = True """ finalize = ", ".join(f"g{i} / s{i}" for i in rng) finalize = f"groups = np.stack(({finalize}))" @@ -841,8 +844,16 @@ def _analysis_helper( for _ in perms: rs.shuffle(clustering) - test(interactions, interaction_clusters, data, clustering, mean, mask, res=res) - + error = test(interactions, interaction_clusters, data, clustering, mean, mask, res=res) + if error: + raise ValueError( + "In the execution of the numba function, " + "an unhandled case was encountered. " + ) + # This is mainly to avoid a numba warning + # Otherwise, the numba function wouldn't be + # executed in parallel + # See: https://github.com/scverse/squidpy/issues/994 if queue is not None: queue.put(Signal.UPDATE) From 40d8d5e3ad62f742c873d92d547d6e670a64b5f1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 08:05:23 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/squidpy/gr/_ligrec.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/squidpy/gr/_ligrec.py b/src/squidpy/gr/_ligrec.py index defdeac6..2ddbd10f 100644 --- a/src/squidpy/gr/_ligrec.py +++ b/src/squidpy/gr/_ligrec.py @@ -846,10 +846,7 @@ def _analysis_helper( rs.shuffle(clustering) error = test(interactions, interaction_clusters, data, clustering, mean, mask, res=res) if error: - raise ValueError( - "In the execution of the numba function, " - "an unhandled case was encountered. " - ) + raise ValueError("In the execution of the numba function, an unhandled case was encountered. ") # This is mainly to avoid a numba warning # Otherwise, the numba function wouldn't be # executed in parallel From daf87bb6804f8980d6e859c038f314090ca14c6e Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 21 May 2025 13:06:33 +0200 Subject: [PATCH 3/4] add filterwarnings to pyproject --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 1143cab9..05433048 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -226,3 +226,8 @@ required-imports = ["from __future__ import annotations"] [tool.ruff.lint.flake8-tidy-imports] # Disallow all relative imports. ban-relative-imports = "all" + +[tool.pytest.ini_options] +filterwarnings = [ + "error:NumbaPerformanceWarning" +] \ No newline at end of file From d02fddee46a0b04f35bfe105b42c50faf1664ab9 Mon Sep 17 00:00:00 2001 From: Ilan Gold Date: Wed, 28 May 2025 11:29:35 +0200 Subject: [PATCH 4/4] Update pyproject.toml --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 05433048..ee90805b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -229,5 +229,5 @@ ban-relative-imports = "all" [tool.pytest.ini_options] filterwarnings = [ - "error:NumbaPerformanceWarning" -] \ No newline at end of file + "error::NumbaPerformanceWarning" +]