Skip to content

Commit

Permalink
Use annotation instead of field for tagged union (#244)
Browse files Browse the repository at this point in the history
also removed non-standard axis
  • Loading branch information
ziw-liu authored Sep 7, 2024
1 parent 4bf8016 commit 319f4f3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions iohub/ngff/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
AfterValidator,
BaseModel,
ConfigDict,
Discriminator,
Field,
NonNegativeInt,
PositiveInt,
Expand Down Expand Up @@ -168,13 +169,11 @@ class TimeAxisMeta(NamedAxisMeta):
)


class NonstandardAxisMeta(NamedAxisMeta):
type: str | None
unit: str | None


"""https://ngff.openmicroscopy.org/0.4/index.html#axes-md"""
AxisMeta = TimeAxisMeta | ChannelAxisMeta | SpaceAxisMeta | NonstandardAxisMeta
AxisMeta = Annotated[
TimeAxisMeta | ChannelAxisMeta | SpaceAxisMeta,
Discriminator("type"),
]


class TransformationMeta(MetaBase):
Expand Down Expand Up @@ -227,7 +226,7 @@ class MultiScaleMeta(VersionMeta):
"""https://ngff.openmicroscopy.org/0.4/index.html#multiscale-md"""

# MUST
axes: list[AxisMeta] = Field(..., discriminator="type")
axes: list[AxisMeta]
# MUST
datasets: list[DatasetMeta]
# SHOULD
Expand Down

0 comments on commit 319f4f3

Please sign in to comment.