Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep .X when setting filename to None #1724

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/anndata/_core/file_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def close(self):

def _to_memory_mode(self):
"""Close the backing file, forget filename, *do* change to memory mode."""
self._adata.__X = self._adata.X[()]
self._adata._X = self._adata.X[()]
self._file.close()
self._file = None
self._filename = None
Expand Down
2 changes: 2 additions & 0 deletions tests/test_backed_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def test_return_to_memory_mode(adata, backing_h5ad):
adata.filename = None
assert not adata.isbacked

assert adata.X is not None

# make sure the previous file had been properly closed
# when setting `adata.filename = None`
# if it hadn’t the following line would throw an error
Expand Down
Loading