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

[pre-commit.ci] pre-commit autoupdate #688

Closed
wants to merge 2 commits into from
Closed
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: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0 # Use the ref you want to point at
rev: v5.0.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
- id: check-ast
Expand All @@ -16,7 +16,7 @@ repos:
- id: check-toml

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.6.5'
rev: 'v0.9.2'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -25,7 +25,7 @@ repos:
types_or: [python, jupyter]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.14.1
hooks:
- id: mypy
entry: python3 -m mypy --config-file pyproject.toml
Expand All @@ -41,7 +41,7 @@ repos:
entry: python3 -m nbstripout

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.7
rev: 1.9.1
hooks:
- id: nbqa-black
- id: nbqa-ruff
Expand Down
2 changes: 1 addition & 1 deletion cyclops/data/df/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, **kwargs: Any) -> None:
if kwargs[FEATURE_TYPE_ATTR] not in FEATURE_TYPES:
raise ValueError(
f"""Feature type '{kwargs[FEATURE_TYPE_ATTR]}'
not in {', '.join(FEATURE_TYPES)}.""",
not in {", ".join(FEATURE_TYPES)}.""",
)

# Set attributes
Expand Down
13 changes: 8 additions & 5 deletions cyclops/data/features/medical_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,14 @@ def decode_example(
use_auth_token = token_per_repo_id.get(repo_id)
except ValueError:
use_auth_token = None
with xopen(
path,
"rb",
use_auth_token=use_auth_token,
) as file_obj, BytesIO(file_obj.read()) as buffer:
with (
xopen(
path,
"rb",
use_auth_token=use_auth_token,
) as file_obj,
BytesIO(file_obj.read()) as buffer,
):
image, metadata = self._read_file_from_bytes(buffer)
metadata["filename_or_obj"] = path

Expand Down
2 changes: 1 addition & 1 deletion cyclops/data/impute.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def _process_imputefunc(
if imputefunc not in IMPUTEFUNCS:
raise ValueError(
f"""Imputefunc string {imputefunc} not supported.
Supporting: {','.join(IMPUTEFUNCS)}""",
Supporting: {",".join(IMPUTEFUNCS)}""",
)
func = IMPUTEFUNCS[imputefunc]
elif callable(imputefunc):
Expand Down
3 changes: 1 addition & 2 deletions cyclops/data/slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,7 @@ def filter_string_contains(
example_values = pa.array(examples[column_name])
if not pa.types.is_string(example_values.type):
raise ValueError(
"Expected string feature, but got feature of type "
f"{example_values.type}.",
f"Expected string feature, but got feature of type {example_values.type}.",
)

# get all the values that contain the given substring
Expand Down
3 changes: 1 addition & 2 deletions cyclops/evaluate/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ def _load_data(
if split is None:
split = choose_split(dataset, **load_dataset_kwargs)
LOGGER.warning(
"Got `split=None` but `dataset` is a string. "
"Using `split=%s` instead.",
"Got `split=None` but `dataset` is a string. Using `split=%s` instead.",
split,
)

Expand Down
5 changes: 2 additions & 3 deletions cyclops/evaluate/fairness/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def evaluate_fairness( # noqa: PLR0912
# input validation and formatting
if not isinstance(dataset, Dataset):
raise TypeError(
"Expected `dataset` to be of type `Dataset`, but got " f"{type(dataset)}.",
f"Expected `dataset` to be of type `Dataset`, but got {type(dataset)}.",
)
if array_lib not in _SUPPORTED_ARRAY_LIBS:
raise NotImplementedError(f"The array library `{array_lib}` is not supported.")
Expand Down Expand Up @@ -520,8 +520,7 @@ def _validate_group_bins(
for group, bins in group_bins.items():
if not isinstance(bins, (list, int)):
raise TypeError(
f"The bins for {group} must be a list or an integer. "
f"Got {type(bins)}.",
f"The bins for {group} must be a list or an integer. Got {type(bins)}.",
)

if isinstance(bins, int) and not 2 <= bins < len(unique_values[group]):
Expand Down
12 changes: 6 additions & 6 deletions cyclops/evaluate/metrics/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,19 +339,19 @@ def __new__( # type: ignore # mypy expects a subclass of Accuracy
zero_division=zero_division,
)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be specified for multiclass classification."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be specified for multiclass classification."
)
return MulticlassAccuracy(
num_classes=num_classes,
top_k=top_k,
average=average,
zero_division=zero_division,
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be specified for multilabel classification."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be specified for multilabel classification."
)
return MultilabelAccuracy(
num_labels=num_labels,
threshold=threshold,
Expand Down
12 changes: 6 additions & 6 deletions cyclops/evaluate/metrics/auroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,18 +336,18 @@ def __new__( # type: ignore # mypy expects a subclass of AUROC
if task == "binary":
return BinaryAUROC(max_fpr=max_fpr, thresholds=thresholds)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be a positive integer."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be a positive integer."
)
return MulticlassAUROC(
num_classes=num_classes,
thresholds=thresholds,
average=average, # type: ignore
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be a positive integer."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be a positive integer."
)
return MultilabelAUROC(
num_labels=num_labels,
thresholds=thresholds,
Expand Down
24 changes: 12 additions & 12 deletions cyclops/evaluate/metrics/f_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ def __new__( # type: ignore # mypy expects a subclass of FbetaScore
zero_division=zero_division,
)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be specified for multiclass classification."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be specified for multiclass classification."
)
return MulticlassFbetaScore(
beta=beta,
num_classes=num_classes,
Expand All @@ -374,9 +374,9 @@ def __new__( # type: ignore # mypy expects a subclass of FbetaScore
zero_division=zero_division,
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be specified for multilabel classification."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be specified for multilabel classification."
)
return MultilabelFbetaScore(
beta=beta,
num_labels=num_labels,
Expand Down Expand Up @@ -682,19 +682,19 @@ def __new__( # type: ignore # mypy expects a subclass of F1Score
zero_division=zero_division,
)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be specified for multiclass classification."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be specified for multiclass classification."
)
return MulticlassF1Score(
num_classes=num_classes,
top_k=top_k,
average=average,
zero_division=zero_division,
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be specified for multilabel classification."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be specified for multilabel classification."
)
return MultilabelF1Score(
num_labels=num_labels,
threshold=threshold,
Expand Down
12 changes: 6 additions & 6 deletions cyclops/evaluate/metrics/functional/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ def accuracy(
zero_division=zero_division,
)
elif task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be specified for multiclass classification."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be specified for multiclass classification."
)
accuracy_score = multiclass_accuracy(
target,
preds,
Expand All @@ -458,9 +458,9 @@ def accuracy(
zero_division=zero_division,
)
elif task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be specified for multilabel classification."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be specified for multilabel classification."
)
accuracy_score = multilabel_accuracy(
target,
preds,
Expand Down
12 changes: 6 additions & 6 deletions cyclops/evaluate/metrics/functional/auroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,9 @@ def auroc(
if task == "binary":
return binary_auroc(target, preds, max_fpr=max_fpr, thresholds=thresholds)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be a positive integer."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be a positive integer."
)
return multiclass_auroc(
target,
preds,
Expand All @@ -585,9 +585,9 @@ def auroc(
average=average, # type: ignore[arg-type]
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be a positive integer."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be a positive integer."
)
return multilabel_auroc(
target,
preds,
Expand Down
12 changes: 6 additions & 6 deletions cyclops/evaluate/metrics/functional/f_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ def fbeta_score(
zero_division=zero_division,
)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be specified for multiclass classification."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be specified for multiclass classification."
)
return multiclass_fbeta_score(
target,
preds,
Expand All @@ -481,9 +481,9 @@ def fbeta_score(
zero_division=zero_division,
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be specified for multilabel classification."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be specified for multilabel classification."
)
return multilabel_fbeta_score(
target,
preds,
Expand Down
24 changes: 12 additions & 12 deletions cyclops/evaluate/metrics/functional/precision_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ def precision(
zero_division=zero_division,
)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be specified for multiclass classification."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be specified for multiclass classification."
)
return multiclass_precision(
target,
preds,
Expand All @@ -439,9 +439,9 @@ def precision(
zero_division=zero_division,
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be specified for multilabel classification."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be specified for multilabel classification."
)
return multilabel_precision(
target,
preds,
Expand Down Expand Up @@ -786,9 +786,9 @@ def recall(
zero_division=zero_division,
)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be specified for multiclass classification."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be specified for multiclass classification."
)
return multiclass_recall(
target,
preds,
Expand All @@ -798,9 +798,9 @@ def recall(
zero_division=zero_division,
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be specified for multilabel classification."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be specified for multilabel classification."
)
return multilabel_recall(
target,
preds,
Expand Down
12 changes: 6 additions & 6 deletions cyclops/evaluate/metrics/functional/precision_recall_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,9 +1056,9 @@ def precision_recall_curve(
pos_label=pos_label,
)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be a positive integer."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be a positive integer."
)

return multiclass_precision_recall_curve(
target,
Expand All @@ -1067,9 +1067,9 @@ def precision_recall_curve(
thresholds=thresholds,
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be a positive integer."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be a positive integer."
)

return multilabel_precision_recall_curve(
target,
Expand Down
12 changes: 6 additions & 6 deletions cyclops/evaluate/metrics/functional/specificity.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ def specificity(
zero_division=zero_division,
)
if task == "multiclass":
assert (
isinstance(num_classes, int) and num_classes > 0
), "Number of classes must be specified for multiclass classification."
assert isinstance(num_classes, int) and num_classes > 0, (
"Number of classes must be specified for multiclass classification."
)
return multiclass_specificity(
target,
preds,
Expand All @@ -446,9 +446,9 @@ def specificity(
zero_division=zero_division,
)
if task == "multilabel":
assert (
isinstance(num_labels, int) and num_labels > 0
), "Number of labels must be specified for multilabel classification."
assert isinstance(num_labels, int) and num_labels > 0, (
"Number of labels must be specified for multilabel classification."
)
return multilabel_specificity(
target,
preds,
Expand Down
Loading
Loading