Skip to content

feat: parallelize per-library spatial graph construction#1144

Open
Marius1311 wants to merge 1 commit intoscverse:mainfrom
quadbio:feat/parallel-spatial-neighbors
Open

feat: parallelize per-library spatial graph construction#1144
Marius1311 wants to merge 1 commit intoscverse:mainfrom
quadbio:feat/parallel-spatial-neighbors

Conversation

@Marius1311
Copy link

Add n_jobs parameter to spatial_neighbors() to compute per-library graphs in parallel via joblib. Defaults to 1 (sequential, no behavior change). Set to -1 to use all CPUs.

When library_key is set, each library's graph is already computed independently, so this is a trivially parallel workload. For datasets with many libraries (e.g., multi-sample spatial transcriptomics), this gives a near-linear speedup.

IMPORTANT: Please search among the Pull requests before creating one.

Description

How has this been tested?

Closes

Add `n_jobs` parameter to `spatial_neighbors()` to compute per-library
graphs in parallel via joblib. Defaults to 1 (sequential, no behavior
change). Set to -1 to use all CPUs.

When `library_key` is set, each library's graph is already computed
independently, so this is a trivially parallel workload. For datasets
with many libraries (e.g., multi-sample spatial transcriptomics), this
gives a near-linear speedup.
@Marius1311 Marius1311 force-pushed the feat/parallel-spatial-neighbors branch from 89f8be4 to 5eda868 Compare March 23, 2026 16:50
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.08%. Comparing base (9690a55) to head (5eda868).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1144      +/-   ##
==========================================
+ Coverage   74.05%   74.08%   +0.03%     
==========================================
  Files          39       39              
  Lines        6495     6503       +8     
  Branches     1122     1122              
==========================================
+ Hits         4810     4818       +8     
  Misses       1230     1230              
  Partials      455      455              
Files with missing lines Coverage Δ
src/squidpy/gr/_build.py 88.88% <100.00%> (+0.36%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant