|
29 | 29 | from anndata._core.index import _fix_slice_bounds |
30 | 30 | from anndata.compat import H5Group, ZarrArray, ZarrGroup |
31 | 31 |
|
| 32 | +from .._settings import settings |
32 | 33 | from ..compat import SpArray, _read_attr |
33 | 34 |
|
34 | 35 | try: |
@@ -236,6 +237,8 @@ def _get_sliceXarray(self, row: slice, col: Sequence[int]) -> ss.csc_matrix: |
236 | 237 | FORMATS = [ |
237 | 238 | BackedFormat("csr", backed_csr_matrix, ss.csr_matrix), |
238 | 239 | BackedFormat("csc", backed_csc_matrix, ss.csc_matrix), |
| 240 | + BackedFormat("csr", backed_csr_matrix, ss.csr_array), |
| 241 | + BackedFormat("csc", backed_csc_matrix, ss.csc_array), |
239 | 242 | ] |
240 | 243 |
|
241 | 244 |
|
@@ -444,7 +447,9 @@ def __getitem__( |
444 | 447 | # If indexing is array x array it returns a backed_sparse_matrix |
445 | 448 | # Not sure what the performance is on that operation |
446 | 449 | if isinstance(sub, BackedSparseMatrix): |
447 | | - return get_memory_class(self.format)(sub) |
| 450 | + return get_memory_class( |
| 451 | + self.format, use_sparray_in_io=settings.shall_use_sparse_array_on_read |
| 452 | + )(sub) |
448 | 453 | else: |
449 | 454 | return sub |
450 | 455 |
|
@@ -582,7 +587,9 @@ def to_memory(self) -> spmatrix | SpArray: |
582 | 587 | ------- |
583 | 588 | The in-memory representation of the sparse matrix. |
584 | 589 | """ |
585 | | - format_class = get_memory_class(self.format) |
| 590 | + format_class = get_memory_class( |
| 591 | + self.format, use_sparray_in_io=settings.shall_use_sparse_array_on_read |
| 592 | + ) |
586 | 593 | mtx = format_class(self.shape, dtype=self.dtype) |
587 | 594 | mtx.data = self.group["data"][...] |
588 | 595 | mtx.indices = self.group["indices"][...] |
|
0 commit comments