Skip to content

Commit 3ae7c76

Browse files
authored
STY Enables black with experimental_string_processing=true (#20412)
1 parent daae053 commit 3ae7c76

File tree

234 files changed

+1361
-1395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+1361
-1395
lines changed

benchmarks/bench_covertype.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,18 @@ def load_data(dtype=np.float32, order="C", random_state=13):
125125
nargs="?",
126126
default=1,
127127
type=int,
128-
help="Number of concurrently running workers for "
129-
"models that support parallelism.",
128+
help=(
129+
"Number of concurrently running workers for "
130+
"models that support parallelism."
131+
),
130132
)
131133
parser.add_argument(
132134
"--order",
133135
nargs="?",
134136
default="C",
135137
type=str,
136138
choices=["F", "C"],
137-
help="Allow to choose between fortran and C ordered " "data",
139+
help="Allow to choose between fortran and C ordered data",
138140
)
139141
parser.add_argument(
140142
"--random-seed",

benchmarks/bench_hist_gradient_boosting_adult.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def predict(est, data_test, target_test):
4242
toc = time()
4343
roc_auc = roc_auc_score(target_test, predicted_proba_test[:, 1])
4444
acc = accuracy_score(target_test, predicted_test)
45-
print(f"predicted in {toc - tic:.3f}s, " f"ROC AUC: {roc_auc:.4f}, ACC: {acc :.4f}")
45+
print(f"predicted in {toc - tic:.3f}s, ROC AUC: {roc_auc:.4f}, ACC: {acc :.4f}")
4646

4747

4848
data = fetch_openml(data_id=179, as_frame=False) # adult dataset

benchmarks/bench_hist_gradient_boosting_higgsboson.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
args = parser.parse_args()
2828

2929
HERE = os.path.dirname(__file__)
30-
URL = "https://archive.ics.uci.edu/ml/machine-learning-databases/00280/" "HIGGS.csv.gz"
30+
URL = "https://archive.ics.uci.edu/ml/machine-learning-databases/00280/HIGGS.csv.gz"
3131
m = Memory(location=args.cache_loc, mmap_mode="r")
3232

3333
n_leaf_nodes = args.n_leaf_nodes
@@ -71,7 +71,7 @@ def predict(est, data_test, target_test):
7171
toc = time()
7272
roc_auc = roc_auc_score(target_test, predicted_proba_test[:, 1])
7373
acc = accuracy_score(target_test, predicted_test)
74-
print(f"predicted in {toc - tic:.3f}s, " f"ROC AUC: {roc_auc:.4f}, ACC: {acc :.4f}")
74+
print(f"predicted in {toc - tic:.3f}s, ROC AUC: {roc_auc:.4f}, ACC: {acc :.4f}")
7575

7676

7777
df = load_data()

benchmarks/bench_isolation_forest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def print_outlier_ratio(y):
143143
predict_time = time() - tstart
144144
fpr, tpr, thresholds = roc_curve(y_test, scoring)
145145
auc_score = auc(fpr, tpr)
146-
label = "%s (AUC: %0.3f, train_time= %0.2fs, " "test_time= %0.2fs)" % (
146+
label = "%s (AUC: %0.3f, train_time= %0.2fs, test_time= %0.2fs)" % (
147147
dat,
148148
auc_score,
149149
fit_time,

benchmarks/bench_isotonic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def bench_isotonic_regression(Y):
6161
"--iterations",
6262
type=int,
6363
required=True,
64-
help="Number of iterations to average timings over " "for each problem size",
64+
help="Number of iterations to average timings over for each problem size",
6565
)
6666
parser.add_argument(
6767
"--log_min_problem_size",

benchmarks/bench_lof.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,8 @@
9898
fpr,
9999
tpr,
100100
lw=1,
101-
label=(
102-
"ROC for %s (area = %0.3f, train-time: %0.2fs)"
103-
% (dataset_name, AUC, fit_time)
104-
),
101+
label="ROC for %s (area = %0.3f, train-time: %0.2fs)"
102+
% (dataset_name, AUC, fit_time),
105103
)
106104

107105
plt.xlim([-0.05, 1.05])

benchmarks/bench_mnist.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,18 @@ def load_data(dtype=np.float32, order="F"):
132132
nargs="?",
133133
default=1,
134134
type=int,
135-
help="Number of concurrently running workers for "
136-
"models that support parallelism.",
135+
help=(
136+
"Number of concurrently running workers for "
137+
"models that support parallelism."
138+
),
137139
)
138140
parser.add_argument(
139141
"--order",
140142
nargs="?",
141143
default="C",
142144
type=str,
143145
choices=["F", "C"],
144-
help="Allow to choose between fortran and C ordered " "data",
146+
help="Allow to choose between fortran and C ordered data",
145147
)
146148
parser.add_argument(
147149
"--random-seed",
@@ -215,15 +217,17 @@ def load_data(dtype=np.float32, order="F"):
215217
print("Classification performance:")
216218
print("===========================")
217219
print(
218-
"{0: <24} {1: >10} {2: >11} {3: >12}"
219-
"".format("Classifier ", "train-time", "test-time", "error-rate")
220+
"{0: <24} {1: >10} {2: >11} {3: >12}".format(
221+
"Classifier ", "train-time", "test-time", "error-rate"
222+
)
220223
)
221224
print("-" * 60)
222225
for name in sorted(args["classifiers"], key=error.get):
223226

224227
print(
225-
"{0: <23} {1: >10.2f}s {2: >10.2f}s {3: >12.4f}"
226-
"".format(name, train_time[name], test_time[name], error[name])
228+
"{0: <23} {1: >10.2f}s {2: >10.2f}s {3: >12.4f}".format(
229+
name, train_time[name], test_time[name], error[name]
230+
)
227231
)
228232

229233
print()

benchmarks/bench_multilabel_metrics.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,15 @@ def _plot(
155155
"metrics",
156156
nargs="*",
157157
default=sorted(METRICS),
158-
help="Specifies metrics to benchmark, defaults to all. "
159-
"Choices are: {}".format(sorted(METRICS)),
158+
help="Specifies metrics to benchmark, defaults to all. Choices are: {}".format(
159+
sorted(METRICS)
160+
),
160161
)
161162
ap.add_argument(
162163
"--formats",
163164
nargs="+",
164165
choices=sorted(FORMATS),
165-
help="Specifies multilabel formats to benchmark " "(defaults to all).",
166+
help="Specifies multilabel formats to benchmark (defaults to all).",
166167
)
167168
ap.add_argument(
168169
"--samples", type=int, default=1000, help="The number of samples to generate"
@@ -178,8 +179,9 @@ def _plot(
178179
"--plot",
179180
choices=["classes", "density", "samples"],
180181
default=None,
181-
help="Plot time with respect to this parameter varying "
182-
"up to the specified value",
182+
help=(
183+
"Plot time with respect to this parameter varying up to the specified value"
184+
),
183185
)
184186
ap.add_argument(
185187
"--n-steps", default=10, type=int, help="Plot this many points for each metric"

benchmarks/bench_plot_incremental_pca.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def plot_feature_times(all_times, batch_size, all_components, data):
4040
)
4141
plt.legend(loc="upper left")
4242
plt.suptitle(
43-
"Algorithm runtime vs. n_components\n \
44-
LFW, size %i x %i"
43+
"Algorithm runtime vs. n_components\n LFW, size %i x %i"
4544
% data.shape
4645
)
4746
plt.xlabel("Number of components (out of max %i)" % data.shape[1])
@@ -57,7 +56,7 @@ def plot_feature_errors(all_errors, batch_size, all_components, data):
5756
label="IncrementalPCA, bsize=%i" % batch_size,
5857
)
5958
plt.legend(loc="lower left")
60-
plt.suptitle("Algorithm error vs. n_components\n" "LFW, size %i x %i" % data.shape)
59+
plt.suptitle("Algorithm error vs. n_components\nLFW, size %i x %i" % data.shape)
6160
plt.xlabel("Number of components (out of max %i)" % data.shape[1])
6261
plt.ylabel("Mean absolute error")
6362

@@ -68,9 +67,8 @@ def plot_batch_times(all_times, n_features, all_batch_sizes, data):
6867
plot_results(all_batch_sizes, all_times["ipca"], label="IncrementalPCA")
6968
plt.legend(loc="lower left")
7069
plt.suptitle(
71-
"Algorithm runtime vs. batch_size for n_components %i\n \
72-
LFW, size %i x %i"
73-
% (n_features, data.shape[0], data.shape[1])
70+
"Algorithm runtime vs. batch_size for n_components %i\n LFW,"
71+
" size %i x %i" % (n_features, data.shape[0], data.shape[1])
7472
)
7573
plt.xlabel("Batch size")
7674
plt.ylabel("Time (seconds)")
@@ -82,9 +80,8 @@ def plot_batch_errors(all_errors, n_features, all_batch_sizes, data):
8280
plot_results(all_batch_sizes, all_errors["ipca"], label="IncrementalPCA")
8381
plt.legend(loc="lower left")
8482
plt.suptitle(
85-
"Algorithm error vs. batch_size for n_components %i\n \
86-
LFW, size %i x %i"
87-
% (n_features, data.shape[0], data.shape[1])
83+
"Algorithm error vs. batch_size for n_components %i\n LFW,"
84+
" size %i x %i" % (n_features, data.shape[0], data.shape[1])
8885
)
8986
plt.xlabel("Batch size")
9087
plt.ylabel("Mean absolute error")

benchmarks/bench_plot_nmf.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,19 @@ def _fit_transform(self, X, y=None, W=None, H=None, update_H=True):
254254

255255
if not isinstance(n_components, numbers.Integral) or n_components <= 0:
256256
raise ValueError(
257-
"Number of components must be a positive integer;"
258-
" got (n_components=%r)" % n_components
257+
"Number of components must be a positive integer; got (n_components=%r)"
258+
% n_components
259259
)
260260
if not isinstance(self.max_iter, numbers.Integral) or self.max_iter < 0:
261261
raise ValueError(
262262
"Maximum number of iterations must be a positive "
263-
"integer; got (max_iter=%r)" % self.max_iter
263+
"integer; got (max_iter=%r)"
264+
% self.max_iter
264265
)
265266
if not isinstance(self.tol, numbers.Number) or self.tol < 0:
266267
raise ValueError(
267-
"Tolerance for stopping criteria must be "
268-
"positive; got (tol=%r)" % self.tol
268+
"Tolerance for stopping criteria must be positive; got (tol=%r)"
269+
% self.tol
269270
)
270271

271272
# check W and H, or initialize them
@@ -306,7 +307,8 @@ def _fit_transform(self, X, y=None, W=None, H=None, update_H=True):
306307
if n_iter == self.max_iter and self.tol > 0:
307308
warnings.warn(
308309
"Maximum number of iteration %d reached. Increase it"
309-
" to improve convergence." % self.max_iter,
310+
" to improve convergence."
311+
% self.max_iter,
310312
ConvergenceWarning,
311313
)
312314

benchmarks/bench_random_projections.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def print_row(clf_type, time_fit, time_transform):
118118
"--n-components",
119119
dest="n_components",
120120
default="auto",
121-
help="Size of the random subspace." " ('auto' or int > 0)",
121+
help="Size of the random subspace. ('auto' or int > 0)",
122122
)
123123

124124
op.add_option(
@@ -149,8 +149,9 @@ def print_row(clf_type, time_fit, time_transform):
149149
"--density",
150150
dest="density",
151151
default=1 / 3,
152-
help="Density used by the sparse random projection."
153-
" ('auto' or float (0.0, 1.0]",
152+
help=(
153+
"Density used by the sparse random projection. ('auto' or float (0.0, 1.0]"
154+
),
154155
)
155156

156157
op.add_option(
@@ -166,9 +167,11 @@ def print_row(clf_type, time_fit, time_transform):
166167
dest="selected_transformers",
167168
default="GaussianRandomProjection,SparseRandomProjection",
168169
type=str,
169-
help="Comma-separated list of transformer to benchmark. "
170-
"Default: %default. Available: "
171-
"GaussianRandomProjection,SparseRandomProjection",
170+
help=(
171+
"Comma-separated list of transformer to benchmark. "
172+
"Default: %default. Available: "
173+
"GaussianRandomProjection,SparseRandomProjection"
174+
),
172175
)
173176

174177
op.add_option(

benchmarks/bench_sample_without_replacement.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ def bench_sample(sampling, n_population, n_samples):
7272
dest="selected_algorithm",
7373
default=default_algorithms,
7474
type=str,
75-
help="Comma-separated list of transformer to benchmark. "
76-
"Default: %default. \nAvailable: %default",
75+
help=(
76+
"Comma-separated list of transformer to benchmark. "
77+
"Default: %default. \nAvailable: %default"
78+
),
7779
)
7880

7981
# op.add_option("--random-seed",

benchmarks/bench_tsne_mnist.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,30 @@ def sanitize(filename):
7474
parser.add_argument(
7575
"--bhtsne",
7676
action="store_true",
77-
help="if set and the reference bhtsne code is "
78-
"correctly installed, run it in the benchmark.",
77+
help=(
78+
"if set and the reference bhtsne code is "
79+
"correctly installed, run it in the benchmark."
80+
),
7981
)
8082
parser.add_argument(
8183
"--all",
8284
action="store_true",
83-
help="if set, run the benchmark with the whole MNIST."
84-
"dataset. Note that it will take up to 1 hour.",
85+
help=(
86+
"if set, run the benchmark with the whole MNIST."
87+
"dataset. Note that it will take up to 1 hour."
88+
),
8589
)
8690
parser.add_argument(
8791
"--profile",
8892
action="store_true",
89-
help="if set, run the benchmark with a memory " "profiler.",
93+
help="if set, run the benchmark with a memory profiler.",
9094
)
9195
parser.add_argument("--verbose", type=int, default=0)
9296
parser.add_argument(
9397
"--pca-components",
9498
type=int,
9599
default=50,
96-
help="Number of principal components for " "preprocessing.",
100+
help="Number of principal components for preprocessing.",
97101
)
98102
args = parser.parse_args()
99103

build_tools/generate_authors_table.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ def key(profile):
117117

118118
def generate_table(contributors):
119119
lines = [
120-
(".. raw :: html\n"),
121-
(" <!-- Generated by generate_authors_table.py -->"),
122-
(' <div class="sk-authors-container">'),
123-
(" <style>"),
124-
(" img.avatar {border-radius: 10px;}"),
125-
(" </style>"),
120+
".. raw :: html\n",
121+
" <!-- Generated by generate_authors_table.py -->",
122+
' <div class="sk-authors-container">',
123+
" <style>",
124+
" img.avatar {border-radius: 10px;}",
125+
" </style>",
126126
]
127127
for contributor in contributors:
128128
lines.append(" <div>")

doc/conf.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
mathjax_path = ""
6262
else:
6363
extensions.append("sphinx.ext.mathjax")
64-
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/" "tex-chtml.js"
64+
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"
6565

6666
autodoc_default_options = {"members": True, "inherited-members": True}
6767

@@ -285,7 +285,7 @@
285285
v = parse(release)
286286
if v.release is None:
287287
raise ValueError(
288-
"Ill-formed version: {!r}. Version should follow " "PEP440".format(version)
288+
"Ill-formed version: {!r}. Version should follow PEP440".format(version)
289289
)
290290

291291
if v.is_devrelease:
@@ -435,9 +435,7 @@ def generate_min_dependency_table(app):
435435

436436
for package, (version, tags) in dependent_packages.items():
437437
output.write(
438-
f"{package:<{package_header_len}} "
439-
f"{version:<{version_header_len}} "
440-
f"{tags}\n"
438+
f"{package:<{package_header_len}} {version:<{version_header_len}} {tags}\n"
441439
)
442440

443441
output.write(
@@ -494,8 +492,10 @@ def setup(app):
494492
warnings.filterwarnings(
495493
"ignore",
496494
category=UserWarning,
497-
message="Matplotlib is currently using agg, which is a"
498-
" non-GUI backend, so cannot show the figure.",
495+
message=(
496+
"Matplotlib is currently using agg, which is a"
497+
" non-GUI backend, so cannot show the figure."
498+
),
499499
)
500500

501501

doc/conftest.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ def setup_unsupervised_learning():
9292
try:
9393
import skimage # noqa
9494
except ImportError:
95-
raise SkipTest(
96-
"Skipping unsupervised_learning.rst, scikit-image " "not installed"
97-
)
95+
raise SkipTest("Skipping unsupervised_learning.rst, scikit-image not installed")
9896
# ignore deprecation warnings from scipy.misc.face
9997
warnings.filterwarnings(
10098
"ignore", "The binary mode of fromstring", DeprecationWarning

0 commit comments

Comments
 (0)