Skip to content

Commit

Permalink
Rename image label
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Dec 10, 2024
1 parent 5aa5386 commit 5f700f2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/ome_zarr_models/v04/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from ome_zarr_models._utils import get_store_path
from ome_zarr_models.base import Base
from ome_zarr_models.v04.image_label import ImageLabel
from ome_zarr_models.v04.image_label import ImageLabelAttrs
from ome_zarr_models.v04.multiscales import Multiscales
from ome_zarr_models.v04.omero import Omero

Expand Down Expand Up @@ -72,7 +72,9 @@ class ImageAttrs(Base):
min_length=1,
)
omero: Omero | None = None
image_labels: Annotated[ImageLabel | None, Field(..., alias="image-label")] = None
image_labels: Annotated[ImageLabelAttrs | None, Field(..., alias="image-label")] = (
None
)

# TODO: validate:
# "image-label groups MUST also contain multiscales metadata and the two "datasets"
Expand Down
8 changes: 4 additions & 4 deletions src/ome_zarr_models/v04/image_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ome_zarr_models._utils import duplicates
from ome_zarr_models.base import Base

__all__ = ["RGBA", "Color", "ImageLabel", "Property", "Source", "Uint8"]
__all__ = ["RGBA", "Color", "ImageLabelAttrs", "Property", "Source", "Uint8"]

Uint8 = Annotated[int, Field(strict=True, ge=0, le=255)]
RGBA = tuple[Uint8, Uint8, Uint8, Uint8]
Expand Down Expand Up @@ -65,7 +65,7 @@ def _parse_colors(colors: tuple[Color] | None) -> tuple[Color] | None:
return colors


def _parse_imagelabel(model: ImageLabel) -> ImageLabel:
def _parse_imagelabel(model: ImageLabelAttrs) -> ImageLabelAttrs:
"""
check that label_values are consistent across properties and colors
"""
Expand All @@ -85,7 +85,7 @@ def _parse_imagelabel(model: ImageLabel) -> ImageLabel:
return model


class ImageLabel(Base):
class ImageLabelAttrs(Base):
"""
image-label metadata.
"""
Expand All @@ -98,5 +98,5 @@ class ImageLabel(Base):
version: Literal["0.4"] | None

@model_validator(mode="after")
def _parse_model(self) -> ImageLabel:
def _parse_model(self) -> ImageLabelAttrs:
return _parse_imagelabel(self)
2 changes: 1 addition & 1 deletion tests/v04/test_bioformats2raw.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ome_zarr_models.v04.bioformats2raw import BioFormats2RawAttrs
from ome_zarr_models.v04._bioformats2raw import BioFormats2RawAttrs
from ome_zarr_models.v04.plate import (
Acquisition,
Column,
Expand Down
8 changes: 5 additions & 3 deletions tests/v04/test_image_label.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from ome_zarr_models.v04.image_label import Color, ImageLabel, Property, Source
from ome_zarr_models.v04.image_label import Color, ImageLabelAttrs, Property, Source
from tests.v04.conftest import read_in_json


def test_image_label_example_json() -> None:
model = read_in_json(json_fname="image_label_example.json", model_cls=ImageLabel)
model = read_in_json(
json_fname="image_label_example.json", model_cls=ImageLabelAttrs
)

assert model == ImageLabel(
assert model == ImageLabelAttrs(
colors=(
Color(label_value=1, rgba=(255, 255, 255, 255)),
Color(label_value=4, rgba=(0, 255, 255, 128)),
Expand Down

0 comments on commit 5f700f2

Please sign in to comment.