Skip to content

ENH: serialize scipy sparse arrays (sparray / dok_array) - #9370

Open
charan-rathore wants to merge 1 commit into
dask:mainfrom
charan-rathore:fix/spmatrix-deprecation-9353
Open

charan-rathore wants to merge 1 commit into
dask:mainfrom
charan-rathore:fix/spmatrix-deprecation-9353

Conversation

@charan-rathore

Copy link
Copy Markdown

Closes #9353

The spmatrix classes are deprecated in favour of sparse arrays, and the array types don't inherit from spmatrix, so they currently get no serialization handlers - transmitting a dok_array (or any other sparray) fails with TypeError: Could not serialize object of type dok_array. This is what reds the nightly CI (14 failures in distributed/protocol/tests/test_scipy.py).

This registers generic dask serialization for scipy.sparse.sparray and adds dok_array handlers mirroring the dok_matrix ones, and parametrizes the scipy protocol tests over both the legacy matrix classes and the modern array classes.

Verified locally: without the scipy.py change the new array parametrizations fail 14/28; with it, 28/28 pass. Ruff clean.

  • Tests added / passed
  • Passes pixi run lint (ran ruff directly on the two changed files - clean; no pixi on this machine)

The spmatrix classes are deprecated in favour of sparse arrays, which
do not inherit from spmatrix and previously had no serialization
handlers registered, so transmitting them failed with
"TypeError: Could not serialize object of type ...".

Register generic dask serialization for scipy.sparse.sparray and add
dok_array handlers mirroring the dok_matrix ones. Parametrize the
scipy protocol tests over both legacy matrix and modern array types.

Fixes dask#9353

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    40 files  ±  0      40 suites  ±0   14h 8m 30s ⏱️ - 6m 26s
 4 174 tests + 14   3 993 ✅ + 15    178 💤 ±0  3 ❌  - 1 
81 198 runs  +241  76 953 ✅ +238  4 241 💤 +3  4 ❌ ±0 

For more details on these failures, see this check.

Results for commit 03d882a. ± Comparison against base commit dc182bd.

@charan-rathore

Copy link
Copy Markdown
Author

CI verdict on the 3 failures: all three are known flakes, unrelated to this change.

This PR only touches scipy sparse serialization and its protocol tests; those files are untouched by the failures above, and the full scipy protocol suite (matrix + array classes) passes. Nothing to change on my side.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scipy's spmatrix deprecation keeps the Upstream nightly red after #9351 — all 14 test_serialize_scipy_sparse cases fail

1 participant