Skip to content

fix: ensure radius values stored in AnnData.uns are writable - #1249

Open
selmanozleyen wants to merge 1 commit into
scverse:mainfrom
selmanozleyen:fix/neighbours-uns-writable
Open

fix: ensure radius values stored in AnnData.uns are writable#1249
selmanozleyen wants to merge 1 commit into
scverse:mainfrom
selmanozleyen:fix/neighbours-uns-writable

Conversation

@selmanozleyen

Copy link
Copy Markdown
Member

Closes #1247

RadiusBuilder and DelaunayBuilder stored an interval radius in
adata.uns['spatial_neighbors']['params'] as the tuple it was passed as.
anndata has no I/O spec for tuples, so any object built with a tuple radius
raised IORegistryError on write_h5ad / write_zarr.

Store a list instead, via a small _radius_to_uns helper. Scalar radii are
unchanged. Note that DelaunayBuilder already normalizes a scalar r to
(0.0, r) in __init__, so spatial_neighbors_delaunay(radius=5.0) now records
[0.0, 5.0] — the same value as before, just writable.

The abstract GraphBuilder.uns_params docstring now states that values must be
writable 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_h5ad rather than only on the stored value.

@selmanozleyen
selmanozleyen requested a review from timtreis August 2, 2026 20:30
@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.31%. Comparing base (ca07e64) to head (9bf4edd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1249      +/-   ##
==========================================
+ Coverage   77.24%   77.31%   +0.06%     
==========================================
  Files          63       63              
  Lines        9378     9380       +2     
  Branches     1579     1579              
==========================================
+ Hits         7244     7252       +8     
+ Misses       1532     1527       -5     
+ Partials      602      601       -1     
Files with missing lines Coverage Δ
src/squidpy/gr/neighbors.py 91.73% <100.00%> (+0.94%) ⬆️

... and 1 file with indirect coverage changes

🚀 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.

radius tuple passed to spatial_neighbors_delaunay cannot be stored in adata.uns

1 participant