8000 Apply ruff/flake8-implicit-str-concat rule ISC001 · scikit-learn/scikit-learn@fb1ec37 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb1ec37

Browse files
Apply ruff/flake8-implicit-str-concat rule ISC001
ISC001 Implicitly concatenated string literals on one line
1 parent 54f6046 commit fb1ec37

File tree

15 files changed

+20
-20
lines changed

15 files changed

+20
-20
lines changed

examples/mixture/plot_concentration_prior.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def plot_results(ax1, ax2, estimator, X, y, title, plot_title=False):
103103
# mean_precision_prior= 0.8 to minimize the influence of the prior
104104
estimators = [
105105
(
106-
"Finite mixture with a Dirichlet distribution\nprior and " r"$\gamma_0=$",
106+
r"Finite mixture with a Dirichlet distribution\nprior and $\gamma_0=$",
107107
BayesianGaussianMixture(
108108
weight_concentration_prior_type="dirichlet_distribution",
109109
n_components=2 * n_components,

maint_tools/sort_whats_new.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def entry_sort_key(s):
2323

2424
for entry in re.split("\n(?=- )", text.strip()):
2525
modules = re.findall(
26-
r":(?:func|meth|mod|class):" r"`(?:[^<`]*<|~)?(?:sklearn.)?([a-z]\w+)", entry
26+
r":(?:func|meth|mod|class):`(?:[^<`]*<|~)?(?:sklearn.)?([a-z]\w+)", entry
2727
)
2828
modules = set(modules)
2929
if len(modules) > 1:

sklearn/compose/tests/test_target.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_transform_target_regressor_error():
3636
)
3737
with pytest.raises(
3838
TypeError,
39-
match=r"fit\(\) got an unexpected " "keyword argument 'sample_weight'",
39+
match=r"fit\(\) got an unexpected keyword argument 'sample_weight'",
4040
):
4141
regr.fit(X, y, sample_weight=sample_weight)
4242

sklearn/datasets/_twenty_newsgroups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def strip_newsgroup_header(text):
115115

116116

117117
_QUOTE_RE = re.compile(
118-
r"(writes in|writes:|wrote:|says:|said:" r"|^In article|^Quoted from|^\||^>)"
118+
r"(writes in|writes:|wrote:|says:|said:|^In article|^Quoted from|^\||^>)"
119119
)
120120

121121

sklearn/datasets/tests/test_samples_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ def test_make_moons_unbalanced():
689689

690690
with pytest.raises(
691691
ValueError,
692-
match=r"`n_samples` can be either an int " r"or a two-element tuple.",
692+
match=r"`n_samples` can be either an int or a two-element tuple.",
693693
):
694694
make_moons(n_samples=(10,))
695695

sklearn/decomposition/tests/test_fastica.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def test_fastica_errors():
367367
with pytest.raises(ValueError, match=r"alpha must be in \[1,2\]"):
368368
fastica(X, fun_args={"alpha": 0})
369369
with pytest.raises(
370-
ValueError, match="w_init has invalid shape.+" r"should be \(3L?, 3L?\)"
370+
ValueError, match=r"w_init has invalid shape.+should be \(3L?, 3L?\)"
371371
):
372372
fastica(X, w_init=w_init)
373373

sklearn/inspection/_plot/tests/test_plot_partial_dependence.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,9 +1186,9 @@ def test_plot_partial_dependence_lines_kw(
11861186
)
11871187

11881188
line = disp.lines_[0, 0, -1]
1189-
assert line.get_color() == expected_colors[0], (
1190-
f"{line.get_color()}!={expected_colors[0]}\n" f"{line_kw} and {pd_line_kw}"
1191-
)
1189+
assert (
1190+
line.get_color() == expected_colors[0]
1191+
), f"{line.get_color()}!={expected_colors[0]}\n{line_kw} and {pd_line_kw}"
11921192
if pd_line_kw is not None:
11931193
if "linestyle" in pd_line_kw:
11941194
assert line.get_linestyle() == pd_line_kw["linestyle"]

sklearn/linear_model/tests/test_ridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def test_ridge_regression_convergence_fail():
524524
rng = np.random.RandomState(0)
525525
y = rng.randn(5)
526526
X = rng.randn(5, 10)
527-
warning_message = r"sparse_cg did not converge after" r" [0-9]+ iterations."
527+
warning_message = r"sparse_cg did not converge after [0-9]+ iterations."
528528
with pytest.warns(ConvergenceWarning, match=warning_message):
529529
ridge_regression(
530530
X, y, alpha=1.0, solver="sparse_cg", tol=0.0, max_iter=None, verbose=1

sklearn/metrics/cluster/tests/test_supervised.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
def test_error_messages_on_wrong_input():
4141
for score_func in score_funcs:
4242
expected = (
43-
r"Found input variables with inconsistent numbers " r"of samples: \[2, 3\]"
43+
r"Found input variables with inconsistent numbers of samples: \[2, 3\]"
4444
)
4545
with pytest.raises(ValueError, match=expected):
4646
score_func([0, 1], [1, 1, 1])

sklearn/metrics/tests/test_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ def test_metrics_pos_label_error_str(metric, y_pred_threshold, dtype_y_str):
18011801
"pass pos_label explicit"
18021802
)
18031803
err_msg_pos_label_1 = (
1804-
r"pos_label=1 is not a valid label. It should be one of " r"\['eggs', 'spam'\]"
1804+
r"pos_label=1 is not a valid label. It should be one of \['eggs', 'spam'\]"
18051805
)
18061806

18071807
pos_label_default = signature(metric).parameters["pos_label"].default

sklearn/metrics/tests/test_pairwise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ def test_pairwise_distances_data_derived_params_error(metric):
15281528

15291529
with pytest.raises(
15301530
ValueError,
1531-
match=rf"The '(V|VI)' parameter is required for the " rf"{metric} metric",
1531+
match=rf"The '(V|VI)' parameter is required for the {metric} metric",
15321532
):
15331533
pairwise_distances(X, Y, metric=metric)
15341534

sklearn/neighbors/tests/test_nca.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def test_verbose(init_name, capsys):
401401
line,
402402
)
403403
assert re.match(
404-
r"\[NeighborhoodComponentsAnalysis\] Training took\ *" r"\d+\.\d{2}s\.",
404+
r"\[NeighborhoodComponentsAnalysis\] Training took\ *\d+\.\d{2}s\.",
405405
lines[-2],
406406
)
407407
assert lines[-1] == ""

sklearn/preprocessing/tests/test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ def test_power_transformer_shape_exception(method):
22792279
# Exceptions should be raised for arrays with different num_columns
22802280
# than during fitting
22812281
wrong_shape_message = (
2282-
r"X has \d+ features, but PowerTransformer is " r"expecting \d+ features"
2282+
r"X has \d+ features, but PowerTransformer is expecting \d+ features"
22832283
)
22842284

22852285
with pytest.raises(ValueError, match=wrong_shape_message):

sklearn/utils/estimator_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,7 @@ def check_estimators_empty_data_messages(name, estimator_orig):
23172317
# the following y should be accepted by both classifiers and regressors
23182318
# and ignored by unsupervised models
23192319
y = _enforce_estimator_tags_y(e, np.array([1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]))
2320-
msg = r"0 feature\(s\) \(shape=\(\d*, 0\)\) while a minimum of \d* " "is required."
2320+
msg = r"0 feature\(s\) \(shape=\(\d*, 0\)\) while a minimum of \d* is required."
23212321
with raises(ValueError, match=msg):
23222322
e.fit(X_zero_features, y)
23232323

sklearn/utils/tests/test_validation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ def test_check_array_accept_large_sparse_raise_exception(X_64bit):
733733

734734
def test_check_array_min_samples_and_features_messages():
735735
# empty list is considered 2D by default:
736-
msg = r"0 feature\(s\) \(shape=\(1, 0\)\) while a minimum of 1 is" " required."
736+
msg = r"0 feature\(s\) \(shape=\(1, 0\)\) while a minimum of 1 is required."
737737
with pytest.raises(ValueError, match=msg):
738738
check_array([[]])
739739

@@ -756,7 +756,7 @@ def test_check_array_min_samples_and_features_messages():
756756
# Simulate a model that would need at least 2 samples to be well defined
757757
X = np.ones((1, 10))
758758
y = np.ones(1)
759-
msg = r"1 sample\(s\) \(shape=\(1, 10\)\) while a minimum of 2 is" " required."
759+
msg = r"1 sample\(s\) \(shape=\(1, 10\)\) while a minimum of 2 is required."
760760
with pytest.raises(ValueError, match=msg):
761761
check_X_y(X, y, ensure_min_samples=2)
762762

@@ -769,7 +769,7 @@ def test_check_array_min_samples_and_features_messages():
769769
# with k=3)
770770
X = np.ones((10, 2))
771771
y = np.ones(2)
772-
msg = r"2 feature\(s\) \(shape=\(10, 2\)\) while a minimum of 3 is" " required."
772+
msg = r"2 feature\(s\) \(shape=\(10, 2\)\) while a minimum of 3 is required."
773773
with pytest.raises(ValueError, match=msg):
774774
check_X_y(X, y, ensure_min_features=3)
775775

@@ -782,7 +782,7 @@ def test_check_array_min_samples_and_features_messages():
782782
# 2D dataset.
783783
X = np.empty(0).reshape(10, 0)
784784
y = np.ones(10)
785-
msg = r"0 feature\(s\) \(shape=\(10, 0\)\) while a minimum of 1 is" " required."
785+
msg = r"0 feature\(s\) \(shape=\(10, 0\)\) while a minimum of 1 is required."
786786
with pytest.raises(ValueError, match=msg):
787787
check_X_y(X, y)
788788

0 commit comments

Comments
 (0)
0