Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c068c15

Browse files
KumoLiuYu0610
authored andcommittedApr 11, 2024
Ignore E704 after update black (Project-MONAI#7422)
Fixes Project-MONAI#7421 ### Description https://pypi.org/project/black/24.1.1/ ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: YunLiu <[email protected]> Signed-off-by: Yu0610 <[email protected]>
1 parent d7b5270 commit c068c15

File tree

9 files changed

+35
-34
lines changed

9 files changed

+35
-34
lines changed
 

‎monai/apps/detection/utils/anchor_utils.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,12 @@ class AnchorGeneratorWithAnchorShape(AnchorGenerator):
369369
def __init__(
370370
self,
371371
feature_map_scales: Sequence[int] | Sequence[float] = (1, 2, 4, 8),
372-
base_anchor_shapes: Sequence[Sequence[int]]
373-
| Sequence[Sequence[float]] = ((32, 32, 32), (48, 20, 20), (20, 48, 20), (20, 20, 48)),
372+
base_anchor_shapes: Sequence[Sequence[int]] | Sequence[Sequence[float]] = (
373+
(32, 32, 32),
374+
(48, 20, 20),
375+
(20, 48, 20),
376+
(20, 20, 48),
377+
),
374378
indexing: str = "ij",
375379
) -> None:
376380
nn.Module.__init__(self)

‎monai/data/decathlon_datalist.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@
2424

2525

2626
@overload
27-
def _compute_path(base_dir: PathLike, element: PathLike, check_path: bool = False) -> str:
28-
...
27+
def _compute_path(base_dir: PathLike, element: PathLike, check_path: bool = False) -> str: ...
2928

3029

3130
@overload
32-
def _compute_path(base_dir: PathLike, element: list[PathLike], check_path: bool = False) -> list[str]:
33-
...
31+
def _compute_path(base_dir: PathLike, element: list[PathLike], check_path: bool = False) -> list[str]: ...
3432

3533

3634
def _compute_path(base_dir, element, check_path=False):

‎monai/losses/image_dissimilarity.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,7 @@ def parzen_windowing_b_spline(self, img: torch.Tensor, order: int) -> tuple[torc
277277
if order == 0:
278278
weight = weight + (sample_bin_matrix < 0.5) + (sample_bin_matrix == 0.5) * 0.5
279279
elif order == 3:
280-
weight = (
281-
weight + (4 - 6 * sample_bin_matrix**2 + 3 * sample_bin_matrix**3) * (sample_bin_matrix < 1) / 6
282-
)
280+
weight = weight + (4 - 6 * sample_bin_matrix**2 + 3 * sample_bin_matrix**3) * (sample_bin_matrix < 1) / 6
283281
weight = weight + (2 - sample_bin_matrix) ** 3 * (sample_bin_matrix >= 1) * (sample_bin_matrix < 2) / 6
284282
else:
285283
raise ValueError(f"Do not support b-spline {order}-order parzen windowing")

‎monai/transforms/utility/dictionary.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1765,9 +1765,9 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> dict[Hashable, N
17651765
LabelToMaskD = LabelToMaskDict = LabelToMaskd
17661766
FgBgToIndicesD = FgBgToIndicesDict = FgBgToIndicesd
17671767
ClassesToIndicesD = ClassesToIndicesDict = ClassesToIndicesd
1768-
ConvertToMultiChannelBasedOnBratsClassesD = (
1769-
ConvertToMultiChannelBasedOnBratsClassesDict
1770-
) = ConvertToMultiChannelBasedOnBratsClassesd
1768+
ConvertToMultiChannelBasedOnBratsClassesD = ConvertToMultiChannelBasedOnBratsClassesDict = (
1769+
ConvertToMultiChannelBasedOnBratsClassesd
1770+
)
17711771
AddExtremePointsChannelD = AddExtremePointsChannelDict = AddExtremePointsChanneld
17721772
TorchVisionD = TorchVisionDict = TorchVisiond
17731773
RandTorchVisionD = RandTorchVisionDict = RandTorchVisiond

‎monai/utils/dist.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,15 @@ def get_dist_device():
5050

5151

5252
@overload
53-
def evenly_divisible_all_gather(data: torch.Tensor, concat: Literal[True]) -> torch.Tensor:
54-
...
53+
def evenly_divisible_all_gather(data: torch.Tensor, concat: Literal[True]) -> torch.Tensor: ...
5554

5655

5756
@overload
58-
def evenly_divisible_all_gather(data: torch.Tensor, concat: Literal[False]) -> list[torch.Tensor]:
59-
...
57+
def evenly_divisible_all_gather(data: torch.Tensor, concat: Literal[False]) -> list[torch.Tensor]: ...
6058

6159

6260
@overload
63-
def evenly_divisible_all_gather(data: torch.Tensor, concat: bool) -> torch.Tensor | list[torch.Tensor]:
64-
...
61+
def evenly_divisible_all_gather(data: torch.Tensor, concat: bool) -> torch.Tensor | list[torch.Tensor]: ...
6562

6663

6764
def evenly_divisible_all_gather(data: torch.Tensor, concat: bool = True) -> torch.Tensor | list[torch.Tensor]:

‎monai/utils/misc.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,11 @@ def star_zip_with(op, *vals):
103103

104104

105105
@overload
106-
def first(iterable: Iterable[T], default: T) -> T:
107-
...
106+
def first(iterable: Iterable[T], default: T) -> T: ...
108107

109108

110109
@overload
111-
def first(iterable: Iterable[T]) -> T | None:
112-
...
110+
def first(iterable: Iterable[T]) -> T | None: ...
113111

114112

115113
def first(iterable: Iterable[T], default: T | None = None) -> T | None:

‎setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ max_line_length = 120
174174
# B907 https://github.com/Project-MONAI/MONAI/issues/5868
175175
# B908 https://github.com/Project-MONAI/MONAI/issues/6503
176176
# B036 https://github.com/Project-MONAI/MONAI/issues/7396
177+
# E704 https://github.com/Project-MONAI/MONAI/issues/7421
177178
ignore =
178179
E203
179180
E501
@@ -188,6 +189,7 @@ ignore =
188189
B907
189190
B908
190191
B036
192+
E704
191193
per_file_ignores = __init__.py: F401, __main__.py: F401
192194
exclude = *.pyi,.git,.eggs,monai/_version.py,versioneer.py,venv,.venv,_version.py
193195

‎tests/test_hilbert_transform.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,17 @@ def test_value(self, arguments, image, expected_data, atol):
180180
@SkipIfNoModule("torch.fft")
181181
class TestHilbertTransformGPU(unittest.TestCase):
182182
@parameterized.expand(
183-
[]
184-
if not torch.cuda.is_available()
185-
else [
186-
TEST_CASE_1D_SINE_GPU,
187-
TEST_CASE_2D_SINE_GPU,
188-
TEST_CASE_3D_SINE_GPU,
189-
TEST_CASE_1D_2CH_SINE_GPU,
190-
TEST_CASE_2D_2CH_SINE_GPU,
191-
],
183+
(
184+
[]
185+
if not torch.cuda.is_available()
186+
else [
187+
TEST_CASE_1D_SINE_GPU,
188+
TEST_CASE_2D_SINE_GPU,
189+
TEST_CASE_3D_SINE_GPU,
190+
TEST_CASE_1D_2CH_SINE_GPU,
191+
TEST_CASE_2D_2CH_SINE_GPU,
192+
]
193+
),
192194
skip_on_empty=True,
193195
)
194196
def test_value(self, arguments, image, expected_data, atol):

‎tests/test_spacing.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@
7474
torch.ones((1, 2, 1, 2)), # data
7575
torch.tensor([[2, 1, 0, 4], [-1, -3, 0, 5], [0, 0, 2.0, 5], [0, 0, 0, 1]]),
7676
{},
77-
torch.tensor([[[[0.75, 0.75]], [[0.75, 0.75]], [[0.75, 0.75]]]])
78-
if USE_COMPILED
79-
else torch.tensor([[[[0.95527864, 0.95527864]], [[1.0, 1.0]], [[1.0, 1.0]]]]),
77+
(
78+
torch.tensor([[[[0.75, 0.75]], [[0.75, 0.75]], [[0.75, 0.75]]]])
79+
if USE_COMPILED
80+
else torch.tensor([[[[0.95527864, 0.95527864]], [[1.0, 1.0]], [[1.0, 1.0]]]])
81+
),
8082
*device,
8183
]
8284
)

0 commit comments

Comments
 (0)
Please sign in to comment.