Skip to content

Fix raw X when leaving backed mode#2460

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

Fix 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
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.61%. Comparing base (829abb6) to head (d16a246).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2460   +/-   ##
=======================================
  Coverage   85.60%   85.61%           
=======================================
  Files          49       49           
  Lines        7671     7673    +2     
=======================================
+ Hits         6567     6569    +2     
  Misses       1104     1104           
Files with missing lines Coverage Δ
src/anndata/_core/file_backing.py 87.50% <100.00%> (+0.19%) ⬆️

@Zethson Zethson added this to the 0.12.17 milestone May 21, 2026
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

2 participants