From 319f4f36c2ca069206014e9b9a6322471d28a107 Mon Sep 17 00:00:00 2001 From: Ziwen Liu <67518483+ziw-liu@users.noreply.github.com> Date: Sat, 7 Sep 2024 13:57:10 -0400 Subject: [PATCH] Use annotation instead of field for tagged union (#244) also removed non-standard axis --- iohub/ngff/models.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/iohub/ngff/models.py b/iohub/ngff/models.py index d94fb5dc..00ed964c 100644 --- a/iohub/ngff/models.py +++ b/iohub/ngff/models.py @@ -17,6 +17,7 @@ AfterValidator, BaseModel, ConfigDict, + Discriminator, Field, NonNegativeInt, PositiveInt, @@ -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): @@ -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