Skip to content

Commit 70a84ea

Browse files
authored
DOC Fix documentation example sparsefuncs_fast (scikit-learn#29526) (scikit-learn#29527)
1 parent a4582c0 commit 70a84ea

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sklearn/utils/sparsefuncs_fast.pyx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,11 @@ def inplace_csr_row_normalize_l1(X):
489489
--------
490490
>>> from scipy.sparse import csr_matrix
491491
>>> from sklearn.utils.sparsefuncs_fast import inplace_csr_row_normalize_l1
492-
>>> X = csr_matrix(([1.0, 2.0, 3.0], [0, 2, 3], [0, 3, 4]), shape=(3, 4))
492+
>>> import numpy as np
493+
>>> indptr = np.array([0, 2, 3, 4])
494+
>>> indices = np.array([0, 1, 2, 3])
495+
>>> data = np.array([1.0, 2.0, 3.0, 4.0])
496+
>>> X = csr_matrix((data, indices, indptr), shape=(3, 4))
493497
>>> X.toarray()
494498
array([[1., 2., 0., 0.],
495499
[0., 0., 3., 0.],
@@ -547,7 +551,11 @@ def inplace_csr_row_normalize_l2(X):
547551
--------
548552
>>> from scipy.sparse import csr_matrix
549553
>>> from sklearn.utils.sparsefuncs_fast import inplace_csr_row_normalize_l2
550-
>>> X = csr_matrix(([1.0, 2.0, 3.0], [0, 2, 3], [0, 3, 4]), shape=(3, 4))
554+
>>> import numpy as np
555+
>>> indptr = np.array([0, 2, 3, 4])
556+
>>> indices = np.array([0, 1, 2, 3])
557+
>>> data = np.array([1.0, 2.0, 3.0, 4.0])
558+
>>> X = csr_matrix((data, indices, indptr), shape=(3, 4))
551559
>>> X.toarray()
552560
array([[1., 2., 0., 0.],
553561
[0., 0., 3., 0.],

0 commit comments

Comments
 (0)