Skip to content

Commit 4d729d6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 34c898e commit 4d729d6

File tree

5 files changed

+9
-25
lines changed

5 files changed

+9
-25
lines changed

monai/apps/deepgrow/dataset.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,7 @@ def _save_data_2d(vol_idx, vol_image, vol_label, dataset_dir, relative_path):
201201
logging.warning(f"Unique labels {unique_labels_count} exceeds 20. Please check if this is correct.")
202202

203203
logging.info(
204-
"{} => Image Shape: {} => {}; Label Shape: {} => {}; Unique Labels: {}".format(
205-
vol_idx,
206-
vol_image.shape,
207-
image_count,
208-
vol_label.shape if vol_label is not None else None,
209-
label_count,
210-
unique_labels_count,
211-
)
204+
f"{vol_idx} => Image Shape: {vol_image.shape} => {image_count}; Label Shape: {vol_label.shape if vol_label is not None else None} => {label_count}; Unique Labels: {unique_labels_count}"
212205
)
213206
return data_list
214207

@@ -259,13 +252,6 @@ def _save_data_3d(vol_idx, vol_image, vol_label, dataset_dir, relative_path):
259252
logging.warning(f"Unique labels {unique_labels_count} exceeds 20. Please check if this is correct.")
260253

261254
logging.info(
262-
"{} => Image Shape: {} => {}; Label Shape: {} => {}; Unique Labels: {}".format(
263-
vol_idx,
264-
vol_image.shape,
265-
image_count,
266-
vol_label.shape if vol_label is not None else None,
267-
label_count,
268-
unique_labels_count,
269-
)
255+
f"{vol_idx} => Image Shape: {vol_image.shape} => {image_count}; Label Shape: {vol_label.shape if vol_label is not None else None} => {label_count}; Unique Labels: {unique_labels_count}"
270256
)
271257
return data_list

monai/handlers/stats_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def _default_iteration_print(self, engine: Engine) -> None:
260260
"ignoring non-scalar output in StatsHandler,"
261261
" make sure `output_transform(engine.state.output)` returns"
262262
" a scalar or dictionary of key and scalar pairs to avoid this warning."
263-
" {}:{}".format(name, type(value))
263+
f" {name}:{type(value)}"
264264
)
265265
continue # not printing multi dimensional output
266266
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:
273273
"ignoring non-scalar output in StatsHandler,"
274274
" make sure `output_transform(engine.state.output)` returns"
275275
" a scalar or a dictionary of key and scalar pairs to avoid this warning."
276-
" {}".format(type(loss))
276+
f" {type(loss)}"
277277
)
278278

279279
if not out_str:

monai/handlers/tensorboard_handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def _default_iteration_writer(self, engine: Engine, writer: SummaryWriter | Summ
257257
"ignoring non-scalar output in TensorBoardStatsHandler,"
258258
" make sure `output_transform(engine.state.output)` returns"
259259
" a scalar or dictionary of key and scalar pairs to avoid this warning."
260-
" {}:{}".format(name, type(value))
260+
f" {name}:{type(value)}"
261261
)
262262
continue # not plot multi dimensional output
263263
self._write_scalar(
@@ -280,7 +280,7 @@ def _default_iteration_writer(self, engine: Engine, writer: SummaryWriter | Summ
280280
"ignoring non-scalar output in TensorBoardStatsHandler,"
281281
" make sure `output_transform(engine.state.output)` returns"
282282
" a scalar or a dictionary of key and scalar pairs to avoid this warning."
283-
" {}".format(type(loss))
283+
f" {type(loss)}"
284284
)
285285
writer.flush()
286286

monai/metrics/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import warnings
1515
from collections.abc import Iterable, Sequence
16-
from functools import lru_cache, partial
16+
from functools import partial, cache
1717
from types import ModuleType
1818
from typing import Any
1919

@@ -465,7 +465,7 @@ def prepare_spacing(
465465
ENCODING_KERNEL = {2: [[8, 4], [2, 1]], 3: [[[128, 64], [32, 16]], [[8, 4], [2, 1]]]}
466466

467467

468-
@lru_cache(maxsize=None)
468+
@cache
469469
def _get_neighbour_code_to_normals_table(device=None):
470470
"""
471471
returns a lookup table. For every binary neighbour code (2x2x2 neighbourhood = 8 neighbours = 8 bits = 256 codes)

tests/profile_subclass/profiling.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ def main():
6363

6464
b_min, b_avg, b_med, b_std = bench(tensor_1, tensor_2)
6565
print(
66-
"Type {} time (microseconds): min: {}, avg: {}, median: {}, and std {}.".format(
67-
t.__name__, (10**6 * b_min), (10**6) * b_avg, (10**6) * b_med, (10**6) * b_std
68-
)
66+
f"Type {t.__name__} time (microseconds): min: {10**6 * b_min}, avg: {(10**6) * b_avg}, median: {(10**6) * b_med}, and std {(10**6) * b_std}."
6967
)
7068

7169

0 commit comments

Comments
 (0)