Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5996d43

Browse files
Use f strings in error messages
1 parent a96dd38 commit 5996d43

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

sklearn/decomposition/_incremental_pca.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ def partial_fit(self, X, y=None, check_input=True):
308308
)
309309
elif self.n_components > n_samples and first_pass:
310310
raise ValueError(
311-
"n_components=%r must be less or equal to the batch number "
312-
"of samples %d for the first partial_fit "
313-
"call." % (self.n_components, n_samples)
311+
f"n_components={self.n_components} must be less or equal to "
312+
f"the batch number of samples {n_samples} for the first "
313+
"partial_fit call."
314314
)
315315
else:
316316
self.n_components_ = self.n_components

sklearn/decomposition/tests/test_incremental_pca.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,8 @@ def test_incremental_pca_validation():
144144
with pytest.raises(
145145
ValueError,
146146
match=(
147-
"n_components={} must be"
148-
" less or equal to the batch number of"
149-
" samples {} for the first partial_fit"
150-
" call.".format(n_components, n_samples)
147+
f"n_components={n_components} must be less or equal to the batch "
148+
f"number of samples {n_samples} for the first partial_fit call."
151149
),
152150
):
153151
IncrementalPCA(n_components=n_components).partial_fit(X)

0 commit comments

Comments
 (0)