diff --git a/src/transformnd/transforms/affine.py b/src/transformnd/transforms/affine.py index 1933599..5508fd3 100644 --- a/src/transformnd/transforms/affine.py +++ b/src/transformnd/transforms/affine.py @@ -78,7 +78,7 @@ def __init__( if np.allclose(np.zeros_like(self._translation), self._translation): self._translation = None - def to_affine(self) -> Self | None: + def to_affine(self) -> Self: return self def cast_matrix(self, namespace, device) -> ArrayT: diff --git a/src/transformnd/transforms/map_axis.py b/src/transformnd/transforms/map_axis.py index fc68f99..c99d691 100644 --- a/src/transformnd/transforms/map_axis.py +++ b/src/transformnd/transforms/map_axis.py @@ -44,7 +44,7 @@ def __init__( def is_identity(self) -> bool: return all(a == b for a, b in enumerate(self.permutation)) - def to_affine(self) -> Affine[ArrayT] | None: + def to_affine(self) -> Affine[ArrayT]: m = np.eye(self.ndims.source) m = m[self.permutation, :] return Affine.from_linear_map(m, spaces=self.spaces) # type: ignore diff --git a/src/transformnd/transforms/project_axis.py b/src/transformnd/transforms/project_axis.py index eed8ae4..e040f5c 100644 --- a/src/transformnd/transforms/project_axis.py +++ b/src/transformnd/transforms/project_axis.py @@ -92,7 +92,7 @@ def apply(self, coords: ArrayT) -> ArrayT: def is_identity(self) -> bool: return not self.created and not self.dropped - def to_affine(self) -> Affine | None: + def to_affine(self) -> Affine: m = np.eye(self.ndims.source) out_m = self.apply(m) return Affine.from_linear_map(out_m.T) diff --git a/src/transformnd/transforms/simple.py b/src/transformnd/transforms/simple.py index 170d9c4..8bdfe45 100644 --- a/src/transformnd/transforms/simple.py +++ b/src/transformnd/transforms/simple.py @@ -42,7 +42,7 @@ def __init__( def invert(self) -> Transform[ArrayT]: return type(self)(self.ndims.source, spaces=self.spaces.invert()) - def to_affine(self) -> Affine[ArrayT] | None: + def to_affine(self) -> Affine[ArrayT]: return Affine[ArrayT].identity(self.ndims.source, spaces=self.spaces) def apply(self, coords: ArrayT) -> ArrayT: @@ -81,7 +81,7 @@ def __init__( NDims(len(self.translation), len(self.translation)), spaces=spaces ) - def to_affine(self) -> Affine[ArrayT] | None: + def to_affine(self) -> Affine[ArrayT]: return Affine[ArrayT].translation(self.translation, spaces=self.spaces) def apply(self, coords: ArrayT) -> ArrayT: @@ -129,7 +129,7 @@ def __init__( raise ValueError(f"Scale must be 1D, got shape {self.scale.shape}") super().__init__(NDims(len(self.scale), len(self.scale)), spaces=spaces) - def to_affine(self) -> Affine[ArrayT] | None: + def to_affine(self) -> Affine[ArrayT]: return Affine[ArrayT].scaling(self.scale, spaces=self.spaces) def apply(self, coords: ArrayT) -> ArrayT: