Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e1e5836

Browse filesBrowse files
committed
MNT apply black to codebase
1 parent 1022ad8 commit e1e5836
Copy full SHA for e1e5836

File tree

135 files changed

+659
-592
lines changed
Filter options

Some content is hidden

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

135 files changed

+659
-592
lines changed

‎sklearn/__check_build/__init__.py

Copy file name to clipboardExpand all lines: sklearn/__check_build/__init__.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def raise_build_error(e):
2828
dir_content.append(filename.ljust(26))
2929
else:
3030
dir_content.append(filename + "\n")
31-
raise ImportError(
32-
"""%s
31+
raise ImportError("""%s
3332
___________________________________________________________________________
3433
Contents of %s:
3534
%s
@@ -39,9 +38,7 @@ def raise_build_error(e):
3938
If you have installed scikit-learn from source, please do not forget
4039
to build the package before using it: run `python setup.py install` or
4140
`make` in the source directory.
42-
%s"""
43-
% (e, local_dir, "".join(dir_content).strip(), msg)
44-
)
41+
%s""" % (e, local_dir, "".join(dir_content).strip(), msg))
4542

4643

4744
try:

‎sklearn/_build_utils/__init__.py

Copy file name to clipboardExpand all lines: sklearn/_build_utils/__init__.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def gen_from_templates(templates):
9797
os.path.exists(outfile)
9898
and os.stat(template).st_mtime < os.stat(outfile).st_mtime
9999
):
100-
101100
with open(template, "r") as f:
102101
tmpl = f.read()
103102

‎sklearn/_build_utils/openmp_helpers.py

Copy file name to clipboardExpand all lines: sklearn/_build_utils/openmp_helpers.py
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,15 @@ def check_openmp_support():
3838
# Pyodide doesn't support OpenMP
3939
return False
4040

41-
code = textwrap.dedent(
42-
"""\
41+
code = textwrap.dedent("""\
4342
#include <omp.h>
4443
#include <stdio.h>
4544
int main(void) {
4645
#pragma omp parallel
4746
printf("nthreads=%d\\n", omp_get_num_threads());
4847
return 0;
4948
}
50-
"""
51-
)
49+
""")
5250

5351
extra_preargs = os.getenv("LDFLAGS", None)
5452
if extra_preargs is not None:
@@ -96,8 +94,7 @@ def check_openmp_support():
9694
"Failed to build scikit-learn with OpenMP support"
9795
) from openmp_exception
9896
else:
99-
message = textwrap.dedent(
100-
"""
97+
message = textwrap.dedent("""
10198
10299
***********
103100
* WARNING *
@@ -120,8 +117,7 @@ def check_openmp_support():
120117
parallelism.
121118
122119
***
123-
"""
124-
)
120+
""")
125121
warnings.warn(message)
126122

127123
return openmp_supported

‎sklearn/_build_utils/pre_build_helpers.py

Copy file name to clipboardExpand all lines: sklearn/_build_utils/pre_build_helpers.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ def basic_check_build():
6464
# The following check won't work in pyodide
6565
return
6666

67-
code = textwrap.dedent(
68-
"""\
67+
code = textwrap.dedent("""\
6968
#include <stdio.h>
7069
int main(void) {
7170
return 0;
7271
}
73-
"""
74-
)
72+
""")
7573
compile_test_program(code)

‎sklearn/base.py

Copy file name to clipboardExpand all lines: sklearn/base.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,11 @@ def set_params(self, **params):
239239
and self.__module__.startswith("sklearn.")
240240
):
241241
warnings.warn(
242-
f"Parameter 'base_estimator' of {self.__class__.__name__} is"
243-
" deprecated in favor of 'estimator'. See"
244-
f" {self.__class__.__name__}'s docstring for more details.",
242+
(
243+
f"Parameter 'base_estimator' of {self.__class__.__name__} is"
244+
" deprecated in favor of 'estimator'. See"
245+
f" {self.__class__.__name__}'s docstring for more details."
246+
),
245247
FutureWarning,
246248
stacklevel=2,
247249
)
@@ -1035,8 +1037,8 @@ class _UnstableArchMixin:
10351037

10361038
def _more_tags(self):
10371039
return {
1038-
"non_deterministic": (
1039-
_IS_32BIT or platform.machine().startswith(("ppc", "powerpc"))
1040+
"non_deterministic": _IS_32BIT or platform.machine().startswith(
1041+
("ppc", "powerpc")
10401042
)
10411043
}
10421044

‎sklearn/calibration.py

Copy file name to clipboardExpand all lines: sklearn/calibration.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,10 @@ def fit(self, X, y, sample_weight=None, **fit_params):
314314
"`estimator` since `base_estimator` is deprecated."
315315
)
316316
warnings.warn(
317-
"`base_estimator` was renamed to `estimator` in version 1.2 and "
318-
"will be removed in 1.4.",
317+
(
318+
"`base_estimator` was renamed to `estimator` in version 1.2 and "
319+
"will be removed in 1.4."
320+
),
319321
FutureWarning,
320322
)
321323
estimator = self.base_estimator

‎sklearn/cluster/_affinity_propagation.py

Copy file name to clipboardExpand all lines: sklearn/cluster/_affinity_propagation.py
+13-8Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ def _affinity_propagation(
141141
if K > 0:
142142
if never_converged:
143143
warnings.warn(
144-
"Affinity propagation did not converge, this model "
145-
"may return degenerate cluster centers and labels.",
144+
(
145+
"Affinity propagation did not converge, this model "
146+
"may return degenerate cluster centers and labels."
147+
),
146148
ConvergenceWarning,
147149
)
148150
c = np.argmax(S[:, I], axis=1)
@@ -161,8 +163,10 @@ def _affinity_propagation(
161163
labels = np.searchsorted(cluster_centers_indices, labels)
162164
else:
163165
warnings.warn(
164-
"Affinity propagation did not converge and this model "
165-
"will not have any cluster centers.",
166+
(
167+
"Affinity propagation did not converge and this model "
168+
"will not have any cluster centers."
169+
),
166170
ConvergenceWarning,
167171
)
168172
labels = np.array([-1] * n_samples)
@@ -453,7 +457,6 @@ def __init__(
453457
verbose=False,
454458
random_state=None,
455459
):
456-
457460
self.damping = damping
458461
self.max_iter = max_iter
459462
self.convergence_iter = convergence_iter
@@ -557,9 +560,11 @@ def predict(self, X):
557560
return pairwise_distances_argmin(X, self.cluster_centers_)
558561
else:
559562
warnings.warn(
560-
"This model does not have any cluster centers "
561-
"because affinity propagation did not converge. "
562-
"Labeling every sample as '-1'.",
563+
(
564+
"This model does not have any cluster centers "
565+
"because affinity propagation did not converge. "
566+
"Labeling every sample as '-1'."
567+
),
563568
ConvergenceWarning,
564569
)
565570
return np.array([-1] * X.shape[0])

‎sklearn/cluster/_agglomerative.py

Copy file name to clipboardExpand all lines: sklearn/cluster/_agglomerative.py
+20-15Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,14 @@ def ward_tree(X, *, connectivity=None, n_clusters=None, return_distance=False):
275275

276276
if n_clusters is not None:
277277
warnings.warn(
278-
"Partial build of the tree is implemented "
279-
"only for structured clustering (i.e. with "
280-
"explicit connectivity). The algorithm "
281-
"will build the full tree and only "
282-
"retain the lower branches required "
283-
"for the specified number of clusters",
278+
(
279+
"Partial build of the tree is implemented "
280+
"only for structured clustering (i.e. with "
281+
"explicit connectivity). The algorithm "
282+
"will build the full tree and only "
283+
"retain the lower branches required "
284+
"for the specified number of clusters"
285+
),
284286
stacklevel=2,
285287
)
286288
X = np.require(X, requirements="W")
@@ -507,12 +509,14 @@ def linkage_tree(
507509

508510
if n_clusters is not None:
509511
warnings.warn(
510-
"Partial build of the tree is implemented "
511-
"only for structured clustering (i.e. with "
512-
"explicit connectivity). The algorithm "
513-
"will build the full tree and only "
514-
"retain the lower branches required "
515-
"for the specified number of clusters",
512+
(
513+
"Partial build of the tree is implemented "
514+
"only for structured clustering (i.e. with "
515+
"explicit connectivity). The algorithm "
516+
"will build the full tree and only "
517+
"retain the lower branches required "
518+
"for the specified number of clusters"
519+
),
516520
stacklevel=2,
517521
)
518522

@@ -541,7 +545,6 @@ def linkage_tree(
541545
and not callable(affinity)
542546
and affinity in METRIC_MAPPING
543547
):
544-
545548
# We need the fast cythonized metric from neighbors
546549
dist_metric = DistanceMetric.get_metric(affinity)
547550

@@ -995,8 +998,10 @@ def _fit(self, X):
995998
" 1.4. To avoid this error, only set the `metric` attribute."
996999
)
9971000
warnings.warn(
998-
"Attribute `affinity` was deprecated in version 1.2 and will be removed"
999-
" in 1.4. Use `metric` instead",
1001+
(
1002+
"Attribute `affinity` was deprecated in version 1.2 and will be"
1003+
" removed in 1.4. Use `metric` instead"
1004+
),
10001005
FutureWarning,
10011006
)
10021007
self._metric = self.affinity

‎sklearn/cluster/_bisect_k_means.py

Copy file name to clipboardExpand all lines: sklearn/cluster/_bisect_k_means.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ def __init__(
226226
algorithm="lloyd",
227227
bisecting_strategy="biggest_inertia",
228228
):
229-
230229
super().__init__(
231230
n_clusters=n_clusters,
232231
init=init,

‎sklearn/cluster/_kmeans.py

Copy file name to clipboardExpand all lines: sklearn/cluster/_kmeans.py
+27-16Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -888,9 +888,11 @@ def _check_params_vs_input(self, X, default_n_init=None):
888888
self._n_init = self.n_init
889889
if self._n_init == "warn":
890890
warnings.warn(
891-
"The default value of `n_init` will change from "
892-
f"{default_n_init} to 'auto' in 1.4. Set the value of `n_init`"
893-
" explicitly to suppress the warning",
891+
(
892+
"The default value of `n_init` will change from "
893+
f"{default_n_init} to 'auto' in 1.4. Set the value of `n_init`"
894+
" explicitly to suppress the warning"
895+
),
894896
FutureWarning,
895897
)
896898
self._n_init = default_n_init
@@ -902,9 +904,11 @@ def _check_params_vs_input(self, X, default_n_init=None):
902904

903905
if _is_arraylike_not_scalar(self.init) and self._n_init != 1:
904906
warnings.warn(
905-
"Explicit initial center position passed: performing only"
906-
f" one init in {self.__class__.__name__} instead of "
907-
f"n_init={self._n_init}.",
907+
(
908+
"Explicit initial center position passed: performing only"
909+
f" one init in {self.__class__.__name__} instead of "
910+
f"n_init={self._n_init}."
911+
),
908912
RuntimeWarning,
909913
stacklevel=2,
910914
)
@@ -1101,8 +1105,10 @@ def predict(self, X, sample_weight="deprecated"):
11011105
X = self._check_test_data(X)
11021106
if not (isinstance(sample_weight, str) and sample_weight == "deprecated"):
11031107
warnings.warn(
1104-
"'sample_weight' was deprecated in version 1.3 and "
1105-
"will be removed in 1.5.",
1108+
(
1109+
"'sample_weight' was deprecated in version 1.3 and "
1110+
"will be removed in 1.5."
1111+
),
11061112
FutureWarning,
11071113
)
11081114
sample_weight = _check_sample_weight(sample_weight, X, dtype=X.dtype)
@@ -1415,15 +1421,19 @@ def _check_params_vs_input(self, X):
14151421
self._algorithm = self.algorithm
14161422
if self._algorithm in ("auto", "full"):
14171423
warnings.warn(
1418-
f"algorithm='{self._algorithm}' is deprecated, it will be "
1419-
"removed in 1.3. Using 'lloyd' instead.",
1424+
(
1425+
f"algorithm='{self._algorithm}' is deprecated, it will be "
1426+
"removed in 1.3. Using 'lloyd' instead."
1427+
),
14201428
FutureWarning,
14211429
)
14221430
self._algorithm = "lloyd"
14231431
if self._algorithm == "elkan" and self.n_clusters == 1:
14241432
warnings.warn(
1425-
"algorithm='elkan' doesn't make sense for a single "
1426-
"cluster. Using 'lloyd' instead.",
1433+
(
1434+
"algorithm='elkan' doesn't make sense for a single "
1435+
"cluster. Using 'lloyd' instead."
1436+
),
14271437
RuntimeWarning,
14281438
)
14291439
self._algorithm = "lloyd"
@@ -1907,7 +1917,6 @@ def __init__(
19071917
n_init="warn",
19081918
reassignment_ratio=0.01,
19091919
):
1910-
19111920
super().__init__(
19121921
n_clusters=n_clusters,
19131922
init=init,
@@ -1937,9 +1946,11 @@ def _check_params_vs_input(self, X):
19371946
self._init_size = 3 * self.n_clusters
19381947
elif self._init_size < self.n_clusters:
19391948
warnings.warn(
1940-
f"init_size={self._init_size} should be larger than "
1941-
f"n_clusters={self.n_clusters}. Setting it to "
1942-
"min(3*n_clusters, n_samples)",
1949+
(
1950+
f"init_size={self._init_size} should be larger than "
1951+
f"n_clusters={self.n_clusters}. Setting it to "
1952+
"min(3*n_clusters, n_samples)"
1953+
),
19431954
RuntimeWarning,
19441955
stacklevel=2,
19451956
)

‎sklearn/cluster/_optics.py

Copy file name to clipboardExpand all lines: sklearn/cluster/_optics.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,10 @@ def compute_optics_graph(
619619
)
620620
if np.all(np.isinf(reachability_)):
621621
warnings.warn(
622-
"All reachability values are inf. Set a larger"
623-
" max_eps or all data will be considered outliers.",
622+
(
623+
"All reachability values are inf. Set a larger"
624+
" max_eps or all data will be considered outliers."
625+
),
624626
UserWarning,
625627
)
626628
return ordering, core_distances_, reachability_, predecessor_

‎sklearn/cluster/_spectral.py

Copy file name to clipboardExpand all lines: sklearn/cluster/_spectral.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ def fit_predict(self, X, y=None):
778778

779779
def _more_tags(self):
780780
return {
781-
"pairwise": self.affinity
782-
in ["precomputed", "precomputed_nearest_neighbors"]
781+
"pairwise": self.affinity in [
782+
"precomputed",
783+
"precomputed_nearest_neighbors",
784+
]
783785
}

‎sklearn/cluster/tests/test_bicluster.py

Copy file name to clipboardExpand all lines: sklearn/cluster/tests/test_bicluster.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ def test_spectral_biclustering(global_random_seed):
105105
for mat in (S, csr_matrix(S)):
106106
for param_name, param_values in non_default_params.items():
107107
for param_value in param_values:
108-
109108
model = SpectralBiclustering(
110109
n_clusters=3,
111110
n_init=3,
@@ -253,7 +252,6 @@ def test_spectralbiclustering_parameter_validation(params, type_err, err_msg):
253252

254253
@pytest.mark.parametrize("est", (SpectralBiclustering(), SpectralCoclustering()))
255254
def test_n_features_in_(est):
256-
257255
X, _, _ = make_biclusters((3, 3), 3, random_state=0)
258256

259257
assert not hasattr(est, "n_features_in_")

‎sklearn/compose/_target.py

Copy file name to clipboardExpand all lines: sklearn/compose/_target.py
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,12 @@ def _fit_transformer(self, y):
188188
y_sel_t = self.transformer_.transform(y_sel)
189189
if not np.allclose(y_sel, self.transformer_.inverse_transform(y_sel_t)):
190190
warnings.warn(
191-
"The provided functions or transformer are"
192-
" not strictly inverse of each other. If"
193-
" you are sure you want to proceed regardless"
194-
", set 'check_inverse=False'",
191+
(
192+
"The provided functions or transformer are"
193+
" not strictly inverse of each other. If"
194+
" you are sure you want to proceed regardless"
195+
", set 'check_inverse=False'"
196+
),
195197
UserWarning,
196198
)
197199

‎sklearn/compose/tests/test_column_transformer.py

Copy file name to clipboardExpand all lines: sklearn/compose/tests/test_column_transformer.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,6 @@ def test_column_transformer_get_feature_names():
803803

804804

805805
def test_column_transformer_special_strings():
806-
807806
# one 'drop' -> ignore
808807
X_array = np.array([[0.0, 1.0, 2.0], [2.0, 4.0, 6.0]]).T
809808
ct = ColumnTransformer([("trans1", Trans(), [0]), ("trans2", "drop", [1])])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.