Skip to content

Commit

Permalink
Adds unit field back to non-reference axes sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomaz-Vieira committed Dec 8, 2023
1 parent dba1def commit b8d074c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bioimageio/spec/model/v0_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@ def __str__(self) -> str:

class FixedSize(Node):
extent: int
unit: "TimeUnit | SpaceUnit" #FIXME: generic?

def transformed(self, *, scale: float = 1.0, offset: int = 0) -> "FixedSize":
return FixedSize(
extent=round(self.extent * scale) + offset,
unit=self.unit,
)

def validate_size(self, size: int) -> int:
Expand All @@ -195,11 +197,13 @@ class ParameterizedSize(Node):

min: Annotated[int, Gt(0)]
step: Annotated[int, Gt(0)]
unit: "TimeUnit | SpaceUnit" #FIXME: generic?

def transformed(self, *, scale: float = 1.0, offset: int = 0) -> "ParameterizedSize":
return ParameterizedSize(
min=round(self.min * scale) + offset, #FIXME: does rounding make sense?
step=round(self.step * scale), #FIXME: does rounding make sense?
unit=self.unit,
)

def validate_size(self, size: int) -> int:
Expand Down

0 comments on commit b8d074c

Please sign in to comment.