From ee1df1632114ccb20170548b279de7e06f1b827d Mon Sep 17 00:00:00 2001 From: maffettone Date: Fri, 5 Apr 2024 10:37:55 -0700 Subject: [PATCH] fix: default false, use bool val for clockwise --- csxtools/image/dask.py | 15 +++++---------- csxtools/image/transform.py | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/csxtools/image/dask.py b/csxtools/image/dask.py index ba69289..9fd0514 100644 --- a/csxtools/image/dask.py +++ b/csxtools/image/dask.py @@ -1,10 +1,8 @@ -from typing import Literal, Union - import dask.array as da from dask.array import Array as DaskArray -def rotate90(images: DaskArray, sense: Union[Literal["cw"], Literal["ccw"]] = "cw") -> DaskArray: +def rotate90(images: DaskArray, sense: bool) -> DaskArray: """ Rotate images by 90 degrees using Dask. This whole function is a moot wrapper around `da.rot90` from Dask, but written @@ -15,9 +13,8 @@ def rotate90(images: DaskArray, sense: Union[Literal["cw"], Literal["ccw"]] = "c images : da.Array Input Dask array of images to rotate of shape (N, y, x), where N is the number of images and y, x are the image dimensions. - sense : str, optional - 'cw' to rotate clockwise, 'ccw' to rotate anticlockwise. - Default is 'cw'. + sense : bool + False to rotate clockwise, True to rotate anticlockwise. Returns ------- @@ -26,11 +23,9 @@ def rotate90(images: DaskArray, sense: Union[Literal["cw"], Literal["ccw"]] = "c """ # Rotate images. The axes (1, 2) specify the plane of rotation (y-x plane for each image). # k controls the direction and repetitions of the rotation. - if sense == "ccw": + if sense: k = 1 - elif sense == "cw": + elif sense: k = -1 - else: - raise ValueError("sense must be 'cw' or 'ccw'") rotated_images = da.rot90(images, k=k, axes=(-2, -1)) return rotated_images diff --git a/csxtools/image/transform.py b/csxtools/image/transform.py index 1828510..754de0c 100644 --- a/csxtools/image/transform.py +++ b/csxtools/image/transform.py @@ -2,7 +2,7 @@ from .dask import rotate90 as dask_rotate90 -def rotate90(a, sense="ccw", *, dask=True): +def rotate90(a, sense="ccw", *, dask=False): """Rotate a stack of images by 90 degrees This routine rotates a stack of images by 90. The rotation is performed