From 5da19ac7f4e97c9026497735e0b3589b7b6df8e1 Mon Sep 17 00:00:00 2001 From: Eljas Roellin Date: Mon, 21 Oct 2024 14:56:40 +0200 Subject: [PATCH 1/2] fix double underscore --- src/anndata/_core/file_backing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anndata/_core/file_backing.py b/src/anndata/_core/file_backing.py index dbef41d5d..6e8c5a558 100644 --- a/src/anndata/_core/file_backing.py +++ b/src/anndata/_core/file_backing.py @@ -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 From 6d603d15782b00485245b2520da15da03e82b51d Mon Sep 17 00:00:00 2001 From: Eljas Roellin Date: Wed, 13 Nov 2024 12:24:45 +0100 Subject: [PATCH 2/2] add a test to check the behavior is correct --- tests/test_backed_hdf5.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_backed_hdf5.py b/tests/test_backed_hdf5.py index 19b4ca44d..2b584ad67 100644 --- a/tests/test_backed_hdf5.py +++ b/tests/test_backed_hdf5.py @@ -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