Skip to content

Commit

Permalink
fix: default false, use bool val for clockwise
Browse files Browse the repository at this point in the history
  • Loading branch information
maffettone committed Apr 5, 2024
1 parent f182f7b commit ee1df16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions csxtools/image/dask.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
-------
Expand All @@ -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
2 changes: 1 addition & 1 deletion csxtools/image/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee1df16

Please sign in to comment.