From 997ac975b75ad5b4e9a77ae247506c853c795edf Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 7 Aug 2021 13:39:50 +0000 Subject: [PATCH 1/3] Replace ternary syntax with if expression --- monai/transforms/io/array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/transforms/io/array.py b/monai/transforms/io/array.py index 2c1a3c89ff..a8e9ed1e7c 100644 --- a/monai/transforms/io/array.py +++ b/monai/transforms/io/array.py @@ -45,7 +45,7 @@ def switch_endianness(data, new="<"): """ if isinstance(data, np.ndarray): # default to system endian - sys_native = ((sys.byteorder == "little") and "<") or ">" + sys_native = "<" if (sys.byteorder == "little") else ">" current_ = sys_native if data.dtype.byteorder not in ("<", ">") else data.dtype.byteorder if new not in ("<", ">"): raise NotImplementedError(f"Not implemented option new={new}.") From e8ad1c44e34aa98ac61697d66de5d2ef5f7bd671 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Sat, 7 Aug 2021 13:58:18 +0100 Subject: [PATCH 2/3] fixes Duplicate dictionary keys PYL-W0109 Signed-off-by: Wenqi Li --- docs/source/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7efebfb8d2..324be8a0fd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -106,7 +106,6 @@ def generate_apidocs(*args): # html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] html_theme_options = { "external_links": [{"url": "https://github.com/Project-MONAI/tutorials", "name": "Tutorials"}], - "collapse_navigation": True, "icon_links": [ { "name": "GitHub", From a6ec47399837de9d5672a2e6f183542f6fa3e5af Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Sat, 7 Aug 2021 14:32:39 +0100 Subject: [PATCH 3/3] remove Unused variable data_ Signed-off-by: Wenqi Li --- monai/data/csv_saver.py | 1 - monai/engines/workflow.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/data/csv_saver.py b/monai/data/csv_saver.py index c79cd1016a..62f407bfd5 100644 --- a/monai/data/csv_saver.py +++ b/monai/data/csv_saver.py @@ -87,7 +87,6 @@ def save(self, data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] """ save_key = meta_data[Key.FILENAME_OR_OBJ] if meta_data else str(self._data_index) self._data_index += 1 - data_: np.ndarray if isinstance(data, torch.Tensor): data = data.detach().cpu().numpy() self._cache_dict[save_key] = np.asarray(data, dtype=float) diff --git a/monai/engines/workflow.py b/monai/engines/workflow.py index 4e1834a625..de3e00c83e 100644 --- a/monai/engines/workflow.py +++ b/monai/engines/workflow.py @@ -149,6 +149,7 @@ def set_sampler_epoch(engine: Engine): self.prepare_batch = prepare_batch self.metric_cmp_fn = metric_cmp_fn self.amp = amp + self.scaler = None if event_names is None: event_names = [IterationEvents]