feat: honor use_sparse_array_on_read in lazy sparse reads - #2566
Open
Kayaba-Attribution wants to merge 1 commit into
Open
feat: honor use_sparse_array_on_read in lazy sparse reads#2566Kayaba-Attribution wants to merge 1 commit into
Kayaba-Attribution wants to merge 1 commit into
Conversation
Make the lazy/dask sparse read path (read_sparse_as_dask) respect
settings.use_sparse_array_on_read, mirroring the in-memory read path, so
lazy/backed reads return cs{r,c}_array consistently instead of always
returning cs{r,c}_matrix. Also widen Raw.X type hints to CSMatrix | CSArray.
Non-breaking foundation for the cs{r,c}_array migration (scverse#2477).
Kayaba-Attribution
force-pushed
the
sparse-array-foundation
branch
from
July 21, 2026 19:42
7f70cf3 to
45ee065
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2566 +/- ##
==========================================
- Coverage 87.81% 85.48% -2.33%
==========================================
Files 49 49
Lines 7799 7801 +2
==========================================
- Hits 6849 6669 -180
- Misses 950 1132 +182
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2477 (foundation PR — intentionally does not close the issue; PRs 2-3 follow).
The first, non-breaking step of the
cs{r,c}_arraymigration.What
read_sparse_as_dask(the lazy/dask sparse read path) now honorssettings.use_sparse_array_on_read, mirroring the in-memory read path (BackedSparseMatrix.memory_format). It previously hardcodedcs{r,c}_matrix, so lazy/backed reads ignored the setting.Raw.__init__'sXparameter and theRaw.Xproperty return type toCSMatrix | CSArray(they wereCSMatrix-only).Why
Preparation for turning
use_sparse_array_on_readon by default: the read paths should agree on the container type first. This removes an inconsistency where in-memory reads honored the setting but lazy reads did not.Notes
use_sparse_array_on_read = False) is unchanged, so behavior is identical unless a user has already opted in.test_read_elem_lazy_honors_sparse_array_setting(csr/csc x array/matrix). The affected modules (test_read.py,test_backed_sparse.py,test_raw.py,test_x.py) pass under--strict-warnings.