Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/transformnd/transforms/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/transformnd/transforms/map_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/transformnd/transforms/project_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/transformnd/transforms/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Loading