Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STY Enables black with experimental_string_processing=true #20412

Merged
merged 2 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions benchmarks/bench_covertype.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,18 @@ def load_data(dtype=np.float32, order="C", random_state=13):
nargs="?",
default=1,
type=int,
help="Number of concurrently running workers for "
"models that support parallelism.",
help=(
"Number of concurrently running workers for "
"models that support parallelism."
),
)
parser.add_argument(
"--order",
nargs="?",
default="C",
type=str,
choices=["F", "C"],
help="Allow to choose between fortran and C ordered " "data",
help="Allow to choose between fortran and C ordered data",
)
parser.add_argument(
"--random-seed",
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_hist_gradient_boosting_adult.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def predict(est, data_test, target_test):
toc = time()
roc_auc = roc_auc_score(target_test, predicted_proba_test[:, 1])
acc = accuracy_score(target_test, predicted_test)
print(f"predicted in {toc - tic:.3f}s, " f"ROC AUC: {roc_auc:.4f}, ACC: {acc :.4f}")
print(f"predicted in {toc - tic:.3f}s, ROC AUC: {roc_auc:.4f}, ACC: {acc :.4f}")


data = fetch_openml(data_id=179, as_frame=False) # adult dataset
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench_hist_gradient_boosting_higgsboson.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
args = parser.parse_args()

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

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


df = load_data()
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_isolation_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def print_outlier_ratio(y):
predict_time = time() - tstart
fpr, tpr, thresholds = roc_curve(y_test, scoring)
auc_score = auc(fpr, tpr)
label = "%s (AUC: %0.3f, train_time= %0.2fs, " "test_time= %0.2fs)" % (
label = "%s (AUC: %0.3f, train_time= %0.2fs, test_time= %0.2fs)" % (
dat,
auc_score,
fit_time,
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_isotonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def bench_isotonic_regression(Y):
"--iterations",
type=int,
required=True,
help="Number of iterations to average timings over " "for each problem size",
help="Number of iterations to average timings over for each problem size",
)
parser.add_argument(
"--log_min_problem_size",
Expand Down
6 changes: 2 additions & 4 deletions benchmarks/bench_lof.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@
fpr,
tpr,
lw=1,
label=(
"ROC for %s (area = %0.3f, train-time: %0.2fs)"
% (dataset_name, AUC, fit_time)
),
label="ROC for %s (area = %0.3f, train-time: %0.2fs)"
% (dataset_name, AUC, fit_time),
)

plt.xlim([-0.05, 1.05])
Expand Down
18 changes: 11 additions & 7 deletions benchmarks/bench_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,18 @@ def load_data(dtype=np.float32, order="F"):
nargs="?",
default=1,
type=int,
help="Number of concurrently running workers for "
"models that support parallelism.",
help=(
"Number of concurrently running workers for "
"models that support parallelism."
),
)
parser.add_argument(
"--order",
nargs="?",
default="C",
type=str,
choices=["F", "C"],
help="Allow to choose between fortran and C ordered " "data",
help="Allow to choose between fortran and C ordered data",
)
parser.add_argument(
"--random-seed",
Expand Down Expand Up @@ -215,15 +217,17 @@ def load_data(dtype=np.float32, order="F"):
print("Classification performance:")
print("===========================")
print(
"{0: <24} {1: >10} {2: >11} {3: >12}"
"".format("Classifier ", "train-time", "test-time", "error-rate")
"{0: <24} {1: >10} {2: >11} {3: >12}".format(
"Classifier ", "train-time", "test-time", "error-rate"
)
)
print("-" * 60)
for name in sorted(args["classifiers"], key=error.get):

print(
"{0: <23} {1: >10.2f}s {2: >10.2f}s {3: >12.4f}"
"".format(name, train_time[name], test_time[name], error[name])
"{0: <23} {1: >10.2f}s {2: >10.2f}s {3: >12.4f}".format(
name, train_time[name], test_time[name], error[name]
)
)

print()
12 changes: 7 additions & 5 deletions benchmarks/bench_multilabel_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ def _plot(
"metrics",
nargs="*",
default=sorted(METRICS),
help="Specifies metrics to benchmark, defaults to all. "
"Choices are: {}".format(sorted(METRICS)),
help="Specifies metrics to benchmark, defaults to all. Choices are: {}".format(
sorted(METRICS)
),
)
ap.add_argument(
"--formats",
nargs="+",
choices=sorted(FORMATS),
help="Specifies multilabel formats to benchmark " "(defaults to all).",
help="Specifies multilabel formats to benchmark (defaults to all).",
)
ap.add_argument(
"--samples", type=int, default=1000, help="The number of samples to generate"
Expand All @@ -178,8 +179,9 @@ def _plot(
"--plot",
choices=["classes", "density", "samples"],
default=None,
help="Plot time with respect to this parameter varying "
"up to the specified value",
help=(
"Plot time with respect to this parameter varying up to the specified value"
),
)
ap.add_argument(
"--n-steps", default=10, type=int, help="Plot this many points for each metric"
Expand Down
15 changes: 6 additions & 9 deletions benchmarks/bench_plot_incremental_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def plot_feature_times(all_times, batch_size, all_components, data):
)
plt.legend(loc="upper left")
plt.suptitle(
"Algorithm runtime vs. n_components\n \
LFW, size %i x %i"
"Algorithm runtime vs. n_components\n LFW, size %i x %i"
% data.shape
)
plt.xlabel("Number of components (out of max %i)" % data.shape[1])
Expand All @@ -57,7 +56,7 @@ def plot_feature_errors(all_errors, batch_size, all_components, data):
label="IncrementalPCA, bsize=%i" % batch_size,
)
plt.legend(loc="lower left")
plt.suptitle("Algorithm error vs. n_components\n" "LFW, size %i x %i" % data.shape)
plt.suptitle("Algorithm error vs. n_components\nLFW, size %i x %i" % data.shape)
plt.xlabel("Number of components (out of max %i)" % data.shape[1])
plt.ylabel("Mean absolute error")

Expand All @@ -68,9 +67,8 @@ def plot_batch_times(all_times, n_features, all_batch_sizes, data):
plot_results(all_batch_sizes, all_times["ipca"], label="IncrementalPCA")
plt.legend(loc="lower left")
plt.suptitle(
"Algorithm runtime vs. batch_size for n_components %i\n \
LFW, size %i x %i"
% (n_features, data.shape[0], data.shape[1])
"Algorithm runtime vs. batch_size for n_components %i\n LFW,"
" size %i x %i" % (n_features, data.shape[0], data.shape[1])
)
plt.xlabel("Batch size")
plt.ylabel("Time (seconds)")
Expand All @@ -82,9 +80,8 @@ def plot_batch_errors(all_errors, n_features, all_batch_sizes, data):
plot_results(all_batch_sizes, all_errors["ipca"], label="IncrementalPCA")
plt.legend(loc="lower left")
plt.suptitle(
"Algorithm error vs. batch_size for n_components %i\n \
LFW, size %i x %i"
% (n_features, data.shape[0], data.shape[1])
"Algorithm error vs. batch_size for n_components %i\n LFW,"
" size %i x %i" % (n_features, data.shape[0], data.shape[1])
)
plt.xlabel("Batch size")
plt.ylabel("Mean absolute error")
Expand Down
14 changes: 8 additions & 6 deletions benchmarks/bench_plot_nmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,19 @@ def _fit_transform(self, X, y=None, W=None, H=None, update_H=True):

if not isinstance(n_components, numbers.Integral) or n_components <= 0:
raise ValueError(
"Number of components must be a positive integer;"
" got (n_components=%r)" % n_components
"Number of components must be a positive integer; got (n_components=%r)"
% n_components
)
if not isinstance(self.max_iter, numbers.Integral) or self.max_iter < 0:
raise ValueError(
"Maximum number of iterations must be a positive "
"integer; got (max_iter=%r)" % self.max_iter
"integer; got (max_iter=%r)"
% self.max_iter
)
if not isinstance(self.tol, numbers.Number) or self.tol < 0:
raise ValueError(
"Tolerance for stopping criteria must be "
"positive; got (tol=%r)" % self.tol
"Tolerance for stopping criteria must be positive; got (tol=%r)"
% self.tol
)

# check W and H, or initialize them
Expand Down Expand Up @@ -306,7 +307,8 @@ def _fit_transform(self, X, y=None, W=None, H=None, update_H=True):
if n_iter == self.max_iter and self.tol > 0:
warnings.warn(
"Maximum number of iteration %d reached. Increase it"
" to improve convergence." % self.max_iter,
" to improve convergence."
% self.max_iter,
ConvergenceWarning,
)

Expand Down
15 changes: 9 additions & 6 deletions benchmarks/bench_random_projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def print_row(clf_type, time_fit, time_transform):
"--n-components",
dest="n_components",
default="auto",
help="Size of the random subspace." " ('auto' or int > 0)",
help="Size of the random subspace. ('auto' or int > 0)",
)

op.add_option(
Expand Down Expand Up @@ -149,8 +149,9 @@ def print_row(clf_type, time_fit, time_transform):
"--density",
dest="density",
default=1 / 3,
help="Density used by the sparse random projection."
" ('auto' or float (0.0, 1.0]",
help=(
"Density used by the sparse random projection. ('auto' or float (0.0, 1.0]"
),
)

op.add_option(
Expand All @@ -166,9 +167,11 @@ def print_row(clf_type, time_fit, time_transform):
dest="selected_transformers",
default="GaussianRandomProjection,SparseRandomProjection",
type=str,
help="Comma-separated list of transformer to benchmark. "
"Default: %default. Available: "
"GaussianRandomProjection,SparseRandomProjection",
help=(
"Comma-separated list of transformer to benchmark. "
"Default: %default. Available: "
"GaussianRandomProjection,SparseRandomProjection"
),
)

op.add_option(
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/bench_sample_without_replacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ def bench_sample(sampling, n_population, n_samples):
dest="selected_algorithm",
default=default_algorithms,
type=str,
help="Comma-separated list of transformer to benchmark. "
"Default: %default. \nAvailable: %default",
help=(
"Comma-separated list of transformer to benchmark. "
"Default: %default. \nAvailable: %default"
),
)

# op.add_option("--random-seed",
Expand Down
16 changes: 10 additions & 6 deletions benchmarks/bench_tsne_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,30 @@ def sanitize(filename):
parser.add_argument(
"--bhtsne",
action="store_true",
help="if set and the reference bhtsne code is "
"correctly installed, run it in the benchmark.",
help=(
"if set and the reference bhtsne code is "
"correctly installed, run it in the benchmark."
),
)
parser.add_argument(
"--all",
action="store_true",
help="if set, run the benchmark with the whole MNIST."
"dataset. Note that it will take up to 1 hour.",
help=(
"if set, run the benchmark with the whole MNIST."
"dataset. Note that it will take up to 1 hour."
),
)
parser.add_argument(
"--profile",
action="store_true",
help="if set, run the benchmark with a memory " "profiler.",
help="if set, run the benchmark with a memory profiler.",
)
parser.add_argument("--verbose", type=int, default=0)
parser.add_argument(
"--pca-components",
type=int,
default=50,
help="Number of principal components for " "preprocessing.",
help="Number of principal components for preprocessing.",
)
args = parser.parse_args()

Expand Down
12 changes: 6 additions & 6 deletions build_tools/generate_authors_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ def key(profile):

def generate_table(contributors):
lines = [
(".. raw :: html\n"),
(" <!-- Generated by generate_authors_table.py -->"),
(' <div class="sk-authors-container">'),
(" <style>"),
(" img.avatar {border-radius: 10px;}"),
(" </style>"),
".. raw :: html\n",
" <!-- Generated by generate_authors_table.py -->",
' <div class="sk-authors-container">',
" <style>",
" img.avatar {border-radius: 10px;}",
" </style>",
]
for contributor in contributors:
lines.append(" <div>")
Expand Down
14 changes: 7 additions & 7 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
mathjax_path = ""
else:
extensions.append("sphinx.ext.mathjax")
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/" "tex-chtml.js"
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"

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

Expand Down Expand Up @@ -285,7 +285,7 @@
v = parse(release)
if v.release is None:
raise ValueError(
"Ill-formed version: {!r}. Version should follow " "PEP440".format(version)
"Ill-formed version: {!r}. Version should follow PEP440".format(version)
)

if v.is_devrelease:
Expand Down Expand Up @@ -435,9 +435,7 @@ def generate_min_dependency_table(app):

for package, (version, tags) in dependent_packages.items():
output.write(
f"{package:<{package_header_len}} "
f"{version:<{version_header_len}} "
f"{tags}\n"
f"{package:<{package_header_len}} {version:<{version_header_len}} {tags}\n"
)

output.write(
Expand Down Expand Up @@ -494,8 +492,10 @@ def setup(app):
warnings.filterwarnings(
"ignore",
category=UserWarning,
message="Matplotlib is currently using agg, which is a"
" non-GUI backend, so cannot show the figure.",
message=(
"Matplotlib is currently using agg, which is a"
" non-GUI backend, so cannot show the figure."
),
)


Expand Down
4 changes: 1 addition & 3 deletions doc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ def setup_unsupervised_learning():
try:
import skimage # noqa
except ImportError:
raise SkipTest(
"Skipping unsupervised_learning.rst, scikit-image " "not installed"
)
raise SkipTest("Skipping unsupervised_learning.rst, scikit-image not installed")
# ignore deprecation warnings from scipy.misc.face
warnings.filterwarnings(
"ignore", "The binary mode of fromstring", DeprecationWarning
Expand Down
Loading