Repository navigation
Conversation
for more information, see https://pre-commit.ci
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SpatialData inputs recompute element centroids on every spatial-neighbor call, even when the selected table already stores the required coordinates (#1199).
Add the keyword-only
coordinate_sourceparameter to all six spatial-neighbor entry points."elements"remains the default;"table"readstable.obsm[spatial_key]directly and skips centroid computation and coordinate transformation. Table mode validates coordinate type, shape and finite values while retaining region and instance association checks.copy=Trueisolates coordinates in the lightweight temporary AnnData;copy=Falsereuses the original array and saves graph results to the table.Includes shared parameter documentation, a usage example and regression tests.
How has this been tested?
git diff --check, pass.Performance
Previously measured at
cbf140don macOS ARM64/Python 3.13.3 with SpatialData 0.8.0: for 100,000 cells across 20 regions, median radius-graph time decreased from 0.68310 s to 0.43761 s (35.9%), and input preparation from 0.28549 s to 0.03208 s. These are medians of five calls using identical synthetic polygons and coordinates, radius 1.6,copy=True,n_jobs=1and single-threaded numerical libraries; imports, warmup and initial coordinate preparation are excluded. Table mode made zero centroid calls and graph outputs matched the AnnData reference.The benchmark script, method and recorded results remain available in the original commit.
Closes
Closes #1199.