Repository navigation
Better scipy.sparse handling - #12722
Merged
Merged
Conversation
Contributor
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 29 files ± 0 29 suites ±0 7h 20m 23s ⏱️ + 40m 32s Results for commit 676737c. ± Comparison against base commit 9c85cb7. ♻️ This comment has been updated with latest results. |
crusaderky
force-pushed
the
fix/scipy-sparse-deprecations
branch
from
November 13, 2026 14:03
acd3c72 to
162b871
Compare
crusaderky
force-pushed
the
fix/scipy-sparse-deprecations
branch
from
November 16, 2026 11:08
681abdb to
f4d5dde
Compare
…f ignoring them The blanket `filterwarnings` ignore in pyproject.toml hides every "is being replaced by" DeprecationWarning, including unrelated ones that could mask real problems. Replace it with per-test assertions that the warning is raised when SciPy >= 2.0.0.dev0, so the deprecation stays visible on older SciPy releases.
…arnings The previous approach blanket-ignored every SciPy spmatrix deprecation warning through a pyproject filterwarnings entry. That hid the warning for generic dask API calls and for users who explicitly asked for a sparse matrix, so the library behaviour was wrong and the filter masked real regressions. Redesign the handling so that the three cases are distinct: * A user who explicitly asks for a scipy.sparse matrix still gets the SciPy deprecation warning unfiltered. The affected tests now assert it on SciPy >= 2.0.0.dev0 and stay silent on older releases. * A user who explicitly asks for scipy.sparse arrays keeps working, and the tests that exercise the array API use the array constructors (eye_array, etc.) so no warning is emitted. * Dask never constructs a sparse matrix on its own. A regression test asserts that generic operations on a csr_array emit no spmatrix deprecation warning. Also harden the library routing: _array_like_safe now identifies SciPy and CuPy sparse containers through a dedicated helper and always constructs the user's own container type. sizeof() gains a scipy.sparse.sparray registration, because sparray is not a subclass of spmatrix and previously fell through to the generic handler, returning a bogus size for sparse arrays.
…sion tests `test_sparse_array` called `scipy.sparse.eye_array`, which does not exist in SciPy 1.11, and the regression test for silent matrix construction called `Array.T`, which SciPy's sparse arrays reject because dask passes an explicit `axes` argument. Guard on the `sparray` API and build the sample with `csr_array(np.eye(...))` instead, and drop the transpose from the regression test.
crusaderky
force-pushed
the
fix/scipy-sparse-deprecations
branch
from
November 16, 2026 23:01
f4d5dde to
9e91607
Compare
scipy.sparse.matrix is deprecated in favour of scipy.sparse.sparray
scipy.sparse.matrix is deprecated in favour of scipy.sparse.sparrayscipy.sparse.matrix is deprecated
scipy.sparse.matrix is deprecatedscipy.sparse handling
crusaderky
marked this pull request as ready for review
November 17, 2026 00:05
crusaderky
added a commit
to crusaderky/distributed
that referenced
this pull request
Nov 25, 2026
…cation SciPy 2 deprecates the sparse matrix classes. Dask must not construct one on its own when the user hands it a sparse array, and must not swallow the warning when the user does hand it a deprecated matrix. Assert the container family in the existing round-trip tests, use `toarray()` instead of `todense()` (which returns the also-deprecated `numpy.matrix`), and add a test that a full sparse-array round trip through the dask serializer emits no "is being replaced by" deprecation warning. Mirrors `test_scipy_sparse_array_never_constructs_matrix` in dask/dask#12722.
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.
sizeofforscipy.sparse.sparrayscipy.sparse.matrixin Scipy 2.0cupyx.scipy.sparseinarray_safe,asarray_safe,asanyarray_safe(untested)