Skip to content

fix(io): read legacy AnnData modality encodings - #212

Open
viranovskaya wants to merge 5 commits into
scverse:mainfrom
viranovskaya:fix/legacy-anndata-encoding-209
Open

viranovskaya wants to merge 5 commits into
scverse:mainfrom
viranovskaya:fix/legacy-anndata-encoding-209

Conversation

@viranovskaya

@viranovskaya viranovskaya commented Oct 11, 2026 •

Copy link
Copy Markdown

Summary

Fixes #209: read .h5mu files written by MuData 0.1.1 and earlier, which used the legacy AnnData / 0.1.0 modality encoding.

Recognize only that exact encoding pair and read its child elements through the existing callbacks. Keep the modern reader, subtype reconstruction, backed reads, and raw handling unchanged. Unknown encodings and unsupported versions still raise an error.

Add regression tests for full-file and single-modality reads, dense and sparse matrices, all three read modes, string and byte attributes, and input-file immutability. Include a changelog entry.

Synced with current main, including the static typing changes in #218. The net diff is limited to the reader, tests, and changelog: three files, +62/−3 lines.

Local validation

  • Without the fix, all 24 legacy cases reproduce IORegistryError on current main; the two unknown-encoding checks pass.
  • Full suites on Python 3.12.14 and 3.14.8, with AnnData 0.13.4 / pandas 3.0.6 / Zarr 3.4.1: 581 passed, 2 existing xfailed, 7 subtests passed each.
  • hatch check types: no issues in 30 source files, using the upstream-configured AnnData-main dependency.
  • Current I/O and subtype tests: 48 passed.
  • The historical minipbcite.h5mu reads through both APIs in all three modes without changing its SHA-256.
  • Applicable project hooks and whitespace checks: passed.

Baseline limitations

  • With AnnData 0.11.4 / Zarr 2.18.7, I/O tests give 44 passed, 4 failed. The same four tests fail on unmodified current main: read_zarr calls require_group on a read-only Zarr 2 group, raising ReadOnlyError. All 26 added regression/control cases pass.
  • A fresh strict documentation build (-W -E -a, Sphinx 9.1.1) reports 16 unresolved type-reference warnings for _AlignedAny and AlignedArray in MuData.obsm/obsp/varm/varp. Unmodified current main produces the identical 16 warnings in the same environment.

These upstream issues are not included in this legacy-reader fix. No dependency pins, warning filters, or type-check suppressions are added.

AI assistance: Codex assisted with implementation, regression tests, and local validation.

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.46%. Comparing base (32adac2) to head (5d94bda).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #212   +/-   ##
=======================================
  Coverage   91.45%   91.46%           
=======================================
  Files          12       12           
  Lines        1885     1887    +2     
=======================================
+ Hits         1724     1726    +2     
  Misses        161      161           
Files with missing lines Coverage Δ
src/mudata/_core/io.py 96.16% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@viranovskaya
viranovskaya marked this pull request as ready for review October 11, 2026 14:19

This branch has not been deployed

No deployments
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.

read_h5mu() fails on files written by mudata <= 0.1.1 (encoding-type "AnnData")

1 participant