@@ -98,28 +98,6 @@ def __init__(
9898 .. warning::
9999
100100 The implementation currently does not support sparse matrices.
101-
102- Examples
103- --------
104- >>> from dask_ml.decomposition import TruncatedSVD
105- >>> import dask.array as da
106- >>> X = da.random.normal(size=(1000, 20), chunks=(100, 20))
107- >>> svd = TruncatedSVD(n_components=5, n_iter=3, random_state=42)
108- >>> svd.fit(X) # doctest: +NORMALIZE_WHITESPACE
109- TruncatedSVD(algorithm='tsqr', n_components=5, n_iter=3,
110- random_state=42, tol=0.0)
111-
112- >>> print(svd.explained_variance_ratio_) # doctest: +ELLIPSIS
113- [0.06386323 0.06176776 0.05901293 0.0576399 0.05726607]
114- >>> print(svd.explained_variance_ratio_.sum()) # doctest: +ELLIPSIS
115- 0.299...
116- >>> print(svd.singular_values_) # doctest: +ELLIPSIS
117- array([35.92469517, 35.32922121, 34.53368856, 34.138..., 34.013...])
118-
119- Note that ``transform`` returns a ``dask.Array``.
120-
121- >>> svd.transform(X)
122- dask.array<sum-agg, shape=(1000, 5), dtype=float64, chunksize=(100, 5)>
123101 """
124102 self .algorithm = algorithm
125103 self .n_components = n_components
@@ -148,7 +126,7 @@ def fit(self, X, y=None):
148126
149127 def _check_array (self , X ):
150128 if self .n_components >= X .shape [1 ]:
151- raise ValueError (
129+ raise ValueError ( # pragma: no cover
152130 "n_components must be < n_features; "
153131 "got {} >= {}" .format (self .n_components , X .shape [1 ])
154132 )
@@ -174,14 +152,14 @@ def fit_transform(self, X, y=None):
174152 """
175153 X = self ._check_array (X )
176154 if self .algorithm not in {"tsqr" , "randomized" }:
177- raise ValueError (
155+ raise ValueError ( # pragma: no cover
178156 "`algorithm` must be 'tsqr' or 'randomized', not '{}'" .format (
179157 self .algorithm
180158 )
181159 )
182160 if self .algorithm == "tsqr" :
183161 if has_keyword (da .linalg .svd , "full_matrices" ):
184- u , s , v = da .linalg .svd (X , full_matrices = False )
162+ u , s , v = da .linalg .svd (X , full_matrices = False ) # pragma: no cover
185163 else :
186164 u , s , v = da .linalg .svd (X )
187165 u = u [:, : self .n_components ]
@@ -245,4 +223,4 @@ def inverse_transform(self, X):
245223 Note that this is always a dense array.
246224 """
247225 # X = check_array(X)
248- return X @ self .components_
226+ return X @ self .components_ # pragma: no cover
0 commit comments