Skip to content

Commit 8b74755

Browse files
authored
Merge pull request #1002 from selmanozleyen/fix/numba-warning
Numba warning fix
2 parents c3277fb + d8b8f91 commit 8b74755

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,8 @@ required-imports = ["from __future__ import annotations"]
226226
[tool.ruff.lint.flake8-tidy-imports]
227227
# Disallow all relative imports.
228228
ban-relative-imports = "all"
229+
230+
[tool.pytest.ini_options]
231+
filterwarnings = [
232+
"error::numba.NumbaPerformanceWarning"
233+
]

src/squidpy/gr/_ligrec.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def _create_template(n_cls: int, return_means: bool = False, parallel: bool = Tr
9393
g{i} = np.zeros((data.shape[1],), dtype=np.float64); s{i} = 0"""
9494
for i in rng
9595
)
96+
init += """
97+
error = False
98+
"""
9699

97100
loop_body = """
98101
if cl == 0:
@@ -110,7 +113,7 @@ def _create_template(n_cls: int, return_means: bool = False, parallel: bool = Tr
110113
cl = clustering[row]
111114
{loop_body}
112115
else:
113-
assert False, "Unhandled case."
116+
error = True
114117
"""
115118
finalize = ", ".join(f"g{i} / s{i}" for i in rng)
116119
finalize = f"groups = np.stack(({finalize}))"
@@ -841,8 +844,13 @@ def _analysis_helper(
841844

842845
for _ in perms:
843846
rs.shuffle(clustering)
844-
test(interactions, interaction_clusters, data, clustering, mean, mask, res=res)
845-
847+
error = test(interactions, interaction_clusters, data, clustering, mean, mask, res=res)
848+
if error:
849+
raise ValueError("In the execution of the numba function, an unhandled case was encountered. ")
850+
# This is mainly to avoid a numba warning
851+
# Otherwise, the numba function wouldn't be
852+
# executed in parallel
853+
# See: https://github.com/scverse/squidpy/issues/994
846854
if queue is not None:
847855
queue.put(Signal.UPDATE)
848856

0 commit comments

Comments
 (0)