From f70de5b4b990b1b883a2aa3c35c8222f5e2c8a43 Mon Sep 17 00:00:00 2001 From: staydelight Date: Mon, 3 Jun 2024 16:25:42 +0800 Subject: [PATCH] Fixes #7557 Fixing unsuccessful checks. Signed-off-by: staydelight --- monai/transforms/io/array.py | 13 ++++++------- monai/transforms/io/dictionary.py | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/monai/transforms/io/array.py b/monai/transforms/io/array.py index 5601b2a20a7..cdcc4da80d3 100644 --- a/monai/transforms/io/array.py +++ b/monai/transforms/io/array.py @@ -14,8 +14,8 @@ from __future__ import annotations -import json import inspect +import json import logging import sys import traceback @@ -394,7 +394,7 @@ def __init__( output_name_formatter: Callable[[dict, Transform], dict] | None = None, folder_layout: FolderLayoutBase | None = None, savepath_in_metadict: bool = False, - mapping_json_path: Path | str | None = None + mapping_json_path: Path | str | None = None, ) -> None: self.folder_layout: FolderLayoutBase if folder_layout is None: @@ -515,10 +515,9 @@ def __call__( meta_data["saved_to"] = filename if self.mapping_json_path and meta_data is not None: log_data = [] - log_data.append({ - "input": meta_data.get("filename_or_obj", ()), - "output": meta_data.get("saved_to", ()) - }) + log_data.append( + {"input": meta_data.get("filename_or_obj", ()), "output": meta_data.get("saved_to", ())} + ) try: with open(self.mapping_json_path) as f: @@ -526,7 +525,7 @@ def __call__( except FileNotFoundError: existing_log_data = [] - with open(self.mapping_json_path, 'w') as f: + with open(self.mapping_json_path, "w") as f: existing_log_data.extend(log_data) json.dump(existing_log_data, f, indent=4) return img diff --git a/monai/transforms/io/dictionary.py b/monai/transforms/io/dictionary.py index e3214777b99..3cf46272c02 100644 --- a/monai/transforms/io/dictionary.py +++ b/monai/transforms/io/dictionary.py @@ -281,7 +281,7 @@ def __init__( output_name_formatter: Callable[[dict, Transform], dict] | None = None, folder_layout: monai.data.FolderLayoutBase | None = None, savepath_in_metadict: bool = False, - mapping_json_path: Path | str | None = None + mapping_json_path: Path | str | None = None, ) -> None: super().__init__(keys, allow_missing_keys) self.meta_keys = ensure_tuple_rep(meta_keys, len(self.keys)) @@ -305,7 +305,7 @@ def __init__( output_name_formatter=output_name_formatter, folder_layout=folder_layout, savepath_in_metadict=savepath_in_metadict, - mapping_json_path= mapping_json_path, + mapping_json_path=mapping_json_path, ) def set_options(self, init_kwargs=None, data_kwargs=None, meta_kwargs=None, write_kwargs=None):