fix: ensure radius values stored in AnnData.uns are writable - #1249
Merged
timtreis merged 8 commits intoAug 11, 2026
Conversation
…rting tuples to lists
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1249 +/- ##
==========================================
+ Coverage 77.08% 78.55% +1.47%
==========================================
Files 63 63
Lines 9436 9505 +69
Branches 1585 1586 +1
==========================================
+ Hits 7274 7467 +193
+ Misses 1561 1448 -113
+ Partials 601 590 -11
🚀 New features to boost your workflow:
|
timtreis
approved these changes
Aug 11, 2026
| GraphPostprocessor = Callable[[GraphMatrixT, GraphMatrixT], tuple[GraphMatrixT, GraphMatrixT]] | ||
|
|
||
|
|
||
| def _radius_to_uns(radius: float | tuple[float, float] | None) -> float | list[float] | None: |
Member
There was a problem hiding this comment.
For clarification - we're doing this do stay backwards compatible? I'm wondering if we need this converter at all or if we should just fix it at creation time.
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.
Closes #1247
RadiusBuilderandDelaunayBuilderstored an intervalradiusinadata.uns['spatial_neighbors']['params']as the tuple it was passed as.anndatahas no I/O spec for tuples, so any object built with a tupleradiusraised
IORegistryErroronwrite_h5ad/write_zarr.Store a list instead, via a small
_radius_to_unshelper. Scalar radii areunchanged. Note that
DelaunayBuilderalready normalizes a scalarrto(0.0, r)in__init__, sospatial_neighbors_delaunay(radius=5.0)now records[0.0, 5.0]— the same value as before, just writable.The abstract
GraphBuilder.uns_paramsdocstring now states that values must bewritable by
anndata, so custom builders don't reintroduce the same problem.Regression test covers both builders with scalar and interval radii, and asserts
on an actual
write_h5adrather than only on the stored value.