Skip to content

Commit e2c0555

Browse files
committed
fixes numba warning
1 parent fef6966 commit e2c0555

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/squidpy/gr/_ligrec.py

Lines changed: 14 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,16 @@ 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(
850+
"In the execution of the numba function, "
851+
"an unhandled case was encountered. "
852+
)
853+
# This is mainly to avoid a numba warning
854+
# Otherwise, the numba function wouldn't be
855+
# executed in parallel
856+
# See: https://github.com/scverse/squidpy/issues/994
846857
if queue is not None:
847858
queue.put(Signal.UPDATE)
848859

0 commit comments

Comments
 (0)