Skip to content

Commit f5e8d3f

Browse files
[pre-commit.ci] Add auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6972ed7 commit f5e8d3f

35 files changed

+222
-209
lines changed

cyclops/data/df/feature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(self, **kwargs: Any) -> None:
6060
if kwargs[FEATURE_TYPE_ATTR] not in FEATURE_TYPES:
6161
raise ValueError(
6262
f"""Feature type '{kwargs[FEATURE_TYPE_ATTR]}'
63-
not in {', '.join(FEATURE_TYPES)}.""",
63+
not in {", ".join(FEATURE_TYPES)}.""",
6464
)
6565

6666
# Set attributes

cyclops/data/features/medical_image.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,14 @@ def decode_example(
209209
use_auth_token = token_per_repo_id.get(repo_id)
210210
except ValueError:
211211
use_auth_token = None
212-
with xopen(
213-
path,
214-
"rb",
215-
use_auth_token=use_auth_token,
216-
) as file_obj, BytesIO(file_obj.read()) as buffer:
212+
with (
213+
xopen(
214+
path,
215+
"rb",
216+
use_auth_token=use_auth_token,
217+
) as file_obj,
218+
BytesIO(file_obj.read()) as buffer,
219+
):
217220
image, metadata = self._read_file_from_bytes(buffer)
218221
metadata["filename_or_obj"] = path
219222

cyclops/data/impute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def _process_imputefunc(
304304
if imputefunc not in IMPUTEFUNCS:
305305
raise ValueError(
306306
f"""Imputefunc string {imputefunc} not supported.
307-
Supporting: {','.join(IMPUTEFUNCS)}""",
307+
Supporting: {",".join(IMPUTEFUNCS)}""",
308308
)
309309
func = IMPUTEFUNCS[imputefunc]
310310
elif callable(imputefunc):

cyclops/data/slicer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,7 @@ def filter_string_contains(
825825
example_values = pa.array(examples[column_name])
826826
if not pa.types.is_string(example_values.type):
827827
raise ValueError(
828-
"Expected string feature, but got feature of type "
829-
f"{example_values.type}.",
828+
f"Expected string feature, but got feature of type {example_values.type}.",
830829
)
831830

832831
# get all the values that contain the given substring

cyclops/evaluate/evaluator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ def _load_data(
170170
if split is None:
171171
split = choose_split(dataset, **load_dataset_kwargs)
172172
LOGGER.warning(
173-
"Got `split=None` but `dataset` is a string. "
174-
"Using `split=%s` instead.",
173+
"Got `split=None` but `dataset` is a string. Using `split=%s` instead.",
175174
split,
176175
)
177176

cyclops/evaluate/fairness/evaluator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def evaluate_fairness( # noqa: PLR0912
150150
# input validation and formatting
151151
if not isinstance(dataset, Dataset):
152152
raise TypeError(
153-
"Expected `dataset` to be of type `Dataset`, but got " f"{type(dataset)}.",
153+
f"Expected `dataset` to be of type `Dataset`, but got {type(dataset)}.",
154154
)
155155
if array_lib not in _SUPPORTED_ARRAY_LIBS:
156156
raise NotImplementedError(f"The array library `{array_lib}` is not supported.")
@@ -520,8 +520,7 @@ def _validate_group_bins(
520520
for group, bins in group_bins.items():
521521
if not isinstance(bins, (list, int)):
522522
raise TypeError(
523-
f"The bins for {group} must be a list or an integer. "
524-
f"Got {type(bins)}.",
523+
f"The bins for {group} must be a list or an integer. Got {type(bins)}.",
525524
)
526525

527526
if isinstance(bins, int) and not 2 <= bins < len(unique_values[group]):

cyclops/evaluate/metrics/accuracy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,19 +339,19 @@ def __new__( # type: ignore # mypy expects a subclass of Accuracy
339339
zero_division=zero_division,
340340
)
341341
if task == "multiclass":
342-
assert (
343-
isinstance(num_classes, int) and num_classes > 0
344-
), "Number of classes must be specified for multiclass classification."
342+
assert isinstance(num_classes, int) and num_classes > 0, (
343+
"Number of classes must be specified for multiclass classification."
344+
)
345345
return MulticlassAccuracy(
346346
num_classes=num_classes,
347347
top_k=top_k,
348348
average=average,
349349
zero_division=zero_division,
350350
)
351351
if task == "multilabel":
352-
assert (
353-
isinstance(num_labels, int) and num_labels > 0
354-
), "Number of labels must be specified for multilabel classification."
352+
assert isinstance(num_labels, int) and num_labels > 0, (
353+
"Number of labels must be specified for multilabel classification."
354+
)
355355
return MultilabelAccuracy(
356356
num_labels=num_labels,
357357
threshold=threshold,

cyclops/evaluate/metrics/auroc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,18 +336,18 @@ def __new__( # type: ignore # mypy expects a subclass of AUROC
336336
if task == "binary":
337337
return BinaryAUROC(max_fpr=max_fpr, thresholds=thresholds)
338338
if task == "multiclass":
339-
assert (
340-
isinstance(num_classes, int) and num_classes > 0
341-
), "Number of classes must be a positive integer."
339+
assert isinstance(num_classes, int) and num_classes > 0, (
340+
"Number of classes must be a positive integer."
341+
)
342342
return MulticlassAUROC(
343343
num_classes=num_classes,
344344
thresholds=thresholds,
345345
average=average, # type: ignore
346346
)
347347
if task == "multilabel":
348-
assert (
349-
isinstance(num_labels, int) and num_labels > 0
350-
), "Number of labels must be a positive integer."
348+
assert isinstance(num_labels, int) and num_labels > 0, (
349+
"Number of labels must be a positive integer."
350+
)
351351
return MultilabelAUROC(
352352
num_labels=num_labels,
353353
thresholds=thresholds,

cyclops/evaluate/metrics/f_beta.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ def __new__( # type: ignore # mypy expects a subclass of FbetaScore
363363
zero_division=zero_division,
364364
)
365365
if task == "multiclass":
366-
assert (
367-
isinstance(num_classes, int) and num_classes > 0
368-
), "Number of classes must be specified for multiclass classification."
366+
assert isinstance(num_classes, int) and num_classes > 0, (
367+
"Number of classes must be specified for multiclass classification."
368+
)
369369
return MulticlassFbetaScore(
370370
beta=beta,
371371
num_classes=num_classes,
@@ -374,9 +374,9 @@ def __new__( # type: ignore # mypy expects a subclass of FbetaScore
374374
zero_division=zero_division,
375375
)
376376
if task == "multilabel":
377-
assert (
378-
isinstance(num_labels, int) and num_labels > 0
379-
), "Number of labels must be specified for multilabel classification."
377+
assert isinstance(num_labels, int) and num_labels > 0, (
378+
"Number of labels must be specified for multilabel classification."
379+
)
380380
return MultilabelFbetaScore(
381381
beta=beta,
382382
num_labels=num_labels,
@@ -682,19 +682,19 @@ def __new__( # type: ignore # mypy expects a subclass of F1Score
682682
zero_division=zero_division,
683683
)
684684
if task == "multiclass":
685-
assert (
686-
isinstance(num_classes, int) and num_classes > 0
687-
), "Number of classes must be specified for multiclass classification."
685+
assert isinstance(num_classes, int) and num_classes > 0, (
686+
"Number of classes must be specified for multiclass classification."
687+
)
688688
return MulticlassF1Score(
689689
num_classes=num_classes,
690690
top_k=top_k,
691691
average=average,
692692
zero_division=zero_division,
693693
)
694694
if task == "multilabel":
695-
assert (
696-
isinstance(num_labels, int) and num_labels > 0
697-
), "Number of labels must be specified for multilabel classification."
695+
assert isinstance(num_labels, int) and num_labels > 0, (
696+
"Number of labels must be specified for multilabel classification."
697+
)
698698
return MultilabelF1Score(
699699
num_labels=num_labels,
700700
threshold=threshold,

cyclops/evaluate/metrics/functional/accuracy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,9 @@ def accuracy(
446446
zero_division=zero_division,
447447
)
448448
elif task == "multiclass":
449-
assert (
450-
isinstance(num_classes, int) and num_classes > 0
451-
), "Number of classes must be specified for multiclass classification."
449+
assert isinstance(num_classes, int) and num_classes > 0, (
450+
"Number of classes must be specified for multiclass classification."
451+
)
452452
accuracy_score = multiclass_accuracy(
453453
target,
454454
preds,
@@ -458,9 +458,9 @@ def accuracy(
458458
zero_division=zero_division,
459459
)
460460
elif task == "multilabel":
461-
assert (
462-
isinstance(num_labels, int) and num_labels > 0
463-
), "Number of labels must be specified for multilabel classification."
461+
assert isinstance(num_labels, int) and num_labels > 0, (
462+
"Number of labels must be specified for multilabel classification."
463+
)
464464
accuracy_score = multilabel_accuracy(
465465
target,
466466
preds,

0 commit comments

Comments
 (0)