Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Change mapping_json_path init way.

Signed-off-by: staydelight <kevin295643815697236@gmail.com>
  • Loading branch information
staydelight committed Jun 1, 2024
1 parent 053ada6 commit 25668ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions monai/transforms/io/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: Union[Path, str, None] = None
mapping_json_path: Path | str | None = None
) -> None:
self.folder_layout: FolderLayoutBase
if folder_layout is None:
Expand Down Expand Up @@ -443,7 +443,7 @@ def __init__(
if mapping_json_path:
self.mapping_json_path = Path(mapping_json_path)
self.savepath_in_metadict = True
else:
else:
self.mapping_json_path = None

def set_options(self, init_kwargs=None, data_kwargs=None, meta_kwargs=None, write_kwargs=None):
Expand Down Expand Up @@ -519,9 +519,9 @@ def __call__(
"input": meta_data.get("filename_or_obj", ()),
"output": meta_data.get("saved_to", ())
})

try:
with open(self.mapping_json_path) as f:
with open(self.mapping_json_path, 'r') as f:
existing_log_data = json.load(f)
except FileNotFoundError:
existing_log_data = []
Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/io/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: Union[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))
Expand Down

0 comments on commit 25668ac

Please sign in to comment.