Skip to content

fix: load raw X when leaving backed mode - #2460

Open
ehsanestaji wants to merge 1 commit into
scverse:mainfrom
ehsanestaji:fix/623-backed-filename-none
Open

fix: load raw X when leaving backed mode#2460
ehsanestaji wants to merge 1 commit into
scverse:mainfrom
ehsanestaji:fix/623-backed-filename-none

Conversation

@ehsanestaji

Copy link
Copy Markdown
  • Release note not necessary because:

Summary

Setting adata.filename = None on a backed object already materialized adata.X, but backed objects read from disk could still lose adata.raw.X because raw._X stayed None after the backing file was closed.

This PR materializes raw.X before leaving backed mode, adds a regression test for the backed-read path, and includes a release note fragment.

Checks

  • uv run pytest tests/test_backed_hdf5.py::test_return_to_memory_mode_loads_raw_X -q
  • uv run pytest tests/test_backed_hdf5.py::test_return_to_memory_mode tests/test_backed_hdf5.py::test_return_to_memory_mode_loads_raw_X tests/test_backed_hdf5.py::test_backed_raw tests/test_raw.py::test_raw_backed -q
  • uv run pytest tests/test_raw.py -q
  • uv run pytest tests/test_backed_hdf5.py -q
  • uv run ruff check src/anndata/_core/file_backing.py tests/test_backed_hdf5.py
  • uv run ruff format --check src/anndata/_core/file_backing.py tests/test_backed_hdf5.py
  • git diff --check

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.87%. Comparing base (c37e213) to head (b5958cd).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2460      +/-   ##
==========================================
- Coverage   87.81%   85.87%   -1.95%     
==========================================
  Files          49       49              
  Lines        7799     7801       +2     
==========================================
- Hits         6849     6699     -150     
- Misses        950     1102     +152     
Files with missing lines Coverage Δ
src/anndata/_core/file_backing.py 87.50% <100.00%> (+0.19%) ⬆️

... and 8 files with indirect coverage changes

@Zethson Zethson added this to the 0.12.17 milestone May 21, 2026
@ilan-gold ilan-gold modified the milestones: 0.12.17, 0.12.18 Jun 16, 2026
@ilan-gold ilan-gold modified the milestones: 0.12.18, 0.12.20, 0.13.1, 0.13.2 Jul 2, 2026
@ilan-gold ilan-gold modified the milestones: 0.13.2, 0.13.3 Jul 13, 2026
@ehsanestaji
ehsanestaji force-pushed the fix/623-backed-filename-none branch from d16a246 to ad7d0f2 Compare July 15, 2026 22:58
@ehsanestaji
ehsanestaji marked this pull request as ready for review July 15, 2026 22:58
@ehsanestaji

Copy link
Copy Markdown
Author

Rebased onto current main and refreshed the PR head.

Local validation:

  • uv run pytest tests/test_backed_hdf5.py tests/test_raw.py -q — 425 passed, 2 xfailed
  • Ruff check and format check passed
  • git diff --check passed

@ehsanestaji ehsanestaji changed the title Fix raw X when leaving backed mode fix: load raw X when leaving backed mode Jul 15, 2026
@ehsanestaji
ehsanestaji force-pushed the fix/623-backed-filename-none branch from ad7d0f2 to b5958cd Compare July 15, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting adata.filename = None doesn't load .X to memory

3 participants