-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Replace pyupgrade with builtin Ruff's UP rule
#8606
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -260,7 +260,7 @@ def _default_iteration_print(self, engine: Engine) -> None: | |
| "ignoring non-scalar output in StatsHandler," | ||
| " make sure `output_transform(engine.state.output)` returns" | ||
| " a scalar or dictionary of key and scalar pairs to avoid this warning." | ||
| " {}:{}".format(name, type(value)) | ||
| f" {name}:{type(value)}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Missing space after colon in f-string. Should be |
||
| ) | ||
| continue # not printing multi dimensional output | ||
| out_str += self.key_var_format.format(name, value.item() if isinstance(value, torch.Tensor) else value) | ||
|
|
@@ -273,7 +273,7 @@ def _default_iteration_print(self, engine: Engine) -> None: | |
| "ignoring non-scalar output in StatsHandler," | ||
| " make sure `output_transform(engine.state.output)` returns" | ||
| " a scalar or a dictionary of key and scalar pairs to avoid this warning." | ||
| " {}".format(type(loss)) | ||
| f" {type(loss)}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Missing space after colon in f-string. Should be |
||
| ) | ||
|
|
||
| if not out_str: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,8 +57,7 @@ def __init__( | |
|
|
||
| if criterion.lower() not in list(AdversarialCriterions): | ||
| raise ValueError( | ||
| "Unrecognised criterion entered for Adversarial Loss. Must be one in: %s" | ||
| % ", ".join(AdversarialCriterions) | ||
| "Unrecognised criterion entered for Adversarial Loss. Must be one in: {}".format(", ".join(AdversarialCriterions)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Using |
||
| ) | ||
|
|
||
| # Depending on the criterion, a different activation layer is used. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,8 +95,7 @@ def __init__( | |
|
|
||
| if network_type.lower() not in list(PercetualNetworkType): | ||
| raise ValueError( | ||
| "Unrecognised criterion entered for Adversarial Loss. Must be one in: %s" | ||
| % ", ".join(PercetualNetworkType) | ||
| "Unrecognised criterion entered for Adversarial Loss. Must be one in: {}".format(", ".join(PercetualNetworkType)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Error message says "Adversarial Loss" but this is the |
||
| ) | ||
|
|
||
| if cache_dir: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Callable, Optional | ||
| from typing import Callable | ||
|
|
||
| import torch | ||
| import torch.nn as nn | ||
|
|
@@ -42,10 +42,10 @@ def sure_loss_function( | |
| operator: Callable, | ||
| x: torch.Tensor, | ||
| y_pseudo_gt: torch.Tensor, | ||
| y_ref: Optional[torch.Tensor] = None, | ||
| eps: Optional[float] = -1.0, | ||
| perturb_noise: Optional[torch.Tensor] = None, | ||
| complex_input: Optional[bool] = False, | ||
| y_ref: torch.Tensor | None = None, | ||
| eps: float | None = -1.0, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: |
||
| perturb_noise: torch.Tensor | None = None, | ||
| complex_input: bool | None = False, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: |
||
| ) -> torch.Tensor: | ||
| """ | ||
| Args: | ||
|
|
@@ -131,7 +131,7 @@ class SURELoss(_Loss): | |
| (https://arxiv.org/pdf/2310.01799.pdf) | ||
| """ | ||
|
|
||
| def __init__(self, perturb_noise: Optional[torch.Tensor] = None, eps: Optional[float] = None) -> None: | ||
| def __init__(self, perturb_noise: torch.Tensor | None = None, eps: float | None = None) -> None: | ||
| """ | ||
| Args: | ||
| perturb_noise (torch.Tensor, optional): The noise vector of shape | ||
|
|
@@ -149,8 +149,8 @@ def forward( | |
| operator: Callable, | ||
| x: torch.Tensor, | ||
| y_pseudo_gt: torch.Tensor, | ||
| y_ref: Optional[torch.Tensor] = None, | ||
| complex_input: Optional[bool] = False, | ||
| y_ref: torch.Tensor | None = None, | ||
| complex_input: bool | None = False, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: same issue: |
||
| ) -> torch.Tensor: | ||
| """ | ||
| Args: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
|
|
||
| import warnings | ||
| from collections.abc import Iterable, Sequence | ||
| from functools import lru_cache, partial | ||
| from functools import partial, cache | ||
| from types import ModuleType | ||
| from typing import Any | ||
|
|
||
|
|
@@ -465,7 +465,7 @@ def prepare_spacing( | |
| ENCODING_KERNEL = {2: [[8, 4], [2, 1]], 3: [[[128, 64], [32, 16]], [[8, 4], [2, 1]]]} | ||
|
|
||
|
|
||
| @lru_cache(maxsize=None) | ||
| @cache | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: The decorator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a valid complaint that should be looked at. |
||
| def _get_neighbour_code_to_normals_table(device=None): | ||
| """ | ||
| returns a lookup table. For every binary neighbour code (2x2x2 neighbourhood = 8 neighbours = 8 bits = 256 codes) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,9 +63,8 @@ def main(): | |||||||||
|
|
||||||||||
| b_min, b_avg, b_med, b_std = bench(tensor_1, tensor_2) | ||||||||||
| print( | ||||||||||
| "Type {} time (microseconds): min: {}, avg: {}, median: {}, and std {}.".format( | ||||||||||
| t.__name__, (10**6 * b_min), (10**6) * b_avg, (10**6) * b_med, (10**6) * b_std | ||||||||||
| ) | ||||||||||
| f"Type {t.__name__} time (microseconds):" | ||||||||||
| f" min: {10**6 * b_min}, avg: {(10**6) * b_avg}, median: {(10**6) * b_med}, and std {(10**6) * b_std}." | ||||||||||
|
Comment on lines
+66
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: f-string split across lines without proper string concatenation or parentheses. Python will treat these as two separate expressions and only print the first line. Lines 66-67 need either parentheses around both strings or explicit concatenation.
Suggested change
|
||||||||||
| ) | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These do not appear to be correct changes for these comments.