diff --git a/sklearn/conftest.py b/sklearn/conftest.py index 203c524561fdd..79fd695fb64f1 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -211,6 +211,10 @@ def pytest_collection_modifyitems(config, items): reason = "Due to NEP 51 numpy scalar repr has changed in numpy 2" skip_doctests = True + if sp_version < parse_version("1.14"): + reason = "Scipy sparse matrix repr has changed in scipy 1.14" + skip_doctests = True + # Normally doctest has the entire module's scope. Here we set globs to an empty dict # to remove the module's scope: # https://docs.python.org/3/library/doctest.html#what-s-the-execution-context diff --git a/sklearn/feature_extraction/image.py b/sklearn/feature_extraction/image.py index 5c7d6efd7fa24..1189618f07feb 100644 --- a/sklearn/feature_extraction/image.py +++ b/sklearn/feature_extraction/image.py @@ -234,6 +234,9 @@ def grid_to_graph( >>> mask[[1, 2], [1, 2], :] = True >>> graph = grid_to_graph(*shape_img, mask=mask) >>> print(graph) + + Coords Values (0, 0) 1 (1, 1) 1 """ diff --git a/sklearn/utils/_indexing.py b/sklearn/utils/_indexing.py index ca2327f2bb109..11ecdfe0ecbd9 100644 --- a/sklearn/utils/_indexing.py +++ b/sklearn/utils/_indexing.py @@ -478,8 +478,8 @@ def resample(*arrays, replace=True, n_samples=None, random_state=None, stratify= [1., 0.]]) >>> X_sparse - <3x2 sparse matrix of type '<... 'numpy.float64'>' - with 4 stored elements in Compressed Sparse Row format> + >>> X_sparse.toarray() array([[1., 0.], @@ -616,8 +616,8 @@ def shuffle(*arrays, random_state=None, n_samples=None): [1., 0.]]) >>> X_sparse - <3x2 sparse matrix of type '<... 'numpy.float64'>' - with 3 stored elements in Compressed Sparse Row format> + >>> X_sparse.toarray() array([[0., 0.], diff --git a/sklearn/utils/validation.py b/sklearn/utils/validation.py index 228fbe76a25e1..af9fdb4a79cba 100644 --- a/sklearn/utils/validation.py +++ b/sklearn/utils/validation.py @@ -501,7 +501,7 @@ def indexable(*iterables): ... [1, 2, 3], np.array([2, 3, 4]), None, csr_matrix([[5], [6], [7]]) ... ] >>> indexable(*iterables) - [[1, 2, 3], array([2, 3, 4]), None, <3x1 sparse matrix ...>] + [[1, 2, 3], array([2, 3, 4]), None, <...Sparse...dtype 'int64'...shape (3, 1)>] """ result = [_make_indexable(X) for X in iterables] @@ -1503,8 +1503,8 @@ def check_symmetric(array, *, tol=1e-10, raise_warning=True, raise_exception=Fal >>> from scipy.sparse import csr_matrix >>> sparse_symmetric_array = csr_matrix(symmetric_array) >>> check_symmetric(sparse_symmetric_array) - <3x3 sparse matrix of type '' - with 6 stored elements in Compressed Sparse Row format> + """ if (array.ndim != 2) or (array.shape[0] != array.shape[1]): raise ValueError(