File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import tempfile
34from types import MappingProxyType
45
56import numpy as np
67import zarr
78from dask .array .core import Array as DaskArray
89from scipy import sparse
910
10- from anndata import AnnData
11+ from anndata import AnnData , concat
1112from anndata ._core .sparse_dataset import sparse_dataset
1213from anndata ._io .specs import write_elem
1314from anndata .experimental import read_elem_lazy
@@ -70,3 +71,26 @@ def peakmem_getitem_adata(self, *_):
7071 res = self .adata [self .slice ]
7172 if isinstance (res , DaskArray ):
7273 res .compute ()
74+
75+
76+ class SparseCSRDask :
77+ def setup (self ):
78+ X = sparse .random (
79+ 10_000 ,
80+ 10_000 ,
81+ density = 0.01 ,
82+ format = "csr" ,
83+ random_state = np .random .default_rng (42 ),
84+ )
85+ self .tmpdir = tempfile .TemporaryDirectory ("tmp.zarr" )
86+ self .group = zarr .group (self .tmpdir .name )
87+ write_elem (self .group , "X" , X )
88+
89+ def time_concat_many (self ):
90+ concat ([AnnData (X = read_elem_lazy (self .group ["X" ])) for i in range (100 )])
91+
92+ def peakmem_concat_many (self ):
93+ concat ([AnnData (X = read_elem_lazy (self .group ["X" ])) for i in range (100 )])
94+
95+ def teardown (self ):
96+ self .tmpdir .cleanup ()
You can’t perform that action at this time.
0 commit comments