From 3195d95d7e0aa7fdcece7028cf3d711842d3e100 Mon Sep 17 00:00:00 2001 From: Nic Ma Date: Tue, 12 Jan 2021 14:53:23 +0800 Subject: [PATCH 1/2] [DLMED] enhance the arg of rotate90 transform Signed-off-by: Nic Ma --- monai/transforms/spatial/array.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py index 40a9a878ad..13ba6fc1d5 100644 --- a/monai/transforms/spatial/array.py +++ b/monai/transforms/spatial/array.py @@ -577,6 +577,9 @@ def __init__(self, k: int = 1, spatial_axes: Tuple[int, int] = (0, 1)) -> None: Default: (0, 1), this is the first two axis in spatial dimensions. """ self.k = k + spatial_axes = ensure_tuple(spatial_axes) + if len(spatial_axes) != 2: + raise ValueError("spatial_axes must be 2 int numbers to indicate the axes to rotate 90 degrees.") self.spatial_axes = spatial_axes def __call__(self, img: np.ndarray) -> np.ndarray: From 93d32d064d9ca760e13f5bdebadc2b4165ab0d8f Mon Sep 17 00:00:00 2001 From: Nic Ma Date: Tue, 12 Jan 2021 15:47:51 +0800 Subject: [PATCH 2/2] [DLMED] fix flake8 issue Signed-off-by: Nic Ma --- monai/transforms/spatial/array.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py index 13ba6fc1d5..26cbf89f33 100644 --- a/monai/transforms/spatial/array.py +++ b/monai/transforms/spatial/array.py @@ -577,10 +577,10 @@ def __init__(self, k: int = 1, spatial_axes: Tuple[int, int] = (0, 1)) -> None: Default: (0, 1), this is the first two axis in spatial dimensions. """ self.k = k - spatial_axes = ensure_tuple(spatial_axes) - if len(spatial_axes) != 2: + spatial_axes_ = ensure_tuple(spatial_axes) + if len(spatial_axes_) != 2: raise ValueError("spatial_axes must be 2 int numbers to indicate the axes to rotate 90 degrees.") - self.spatial_axes = spatial_axes + self.spatial_axes = spatial_axes_ def __call__(self, img: np.ndarray) -> np.ndarray: """