Skip to content

Commit

Permalink
Add well group for v05 (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby authored Jan 20, 2025
1 parent 762f1c4 commit 6a3680c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/ome_zarr_models/_v05/well.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pydantic_zarr.v2 import ArraySpec, GroupSpec

from ome_zarr_models._v05.base import BaseGroupv05, BaseOMEAttrs
from ome_zarr_models.v04.well import WellAttrs

__all__ = ["Well", "WellAttrs"]


class OMEWellAttrs(BaseOMEAttrs):
ome: WellAttrs


class Well(GroupSpec[OMEWellAttrs, ArraySpec | GroupSpec], BaseGroupv05): # type: ignore[misc]
"""
An OME-Zarr well dataset.
"""
3 changes: 3 additions & 0 deletions src/ome_zarr_models/_v05/well_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ome_zarr_models.v04.well_types import WellImage, WellMeta

__all__ = ["WellImage", "WellMeta"]
1 change: 0 additions & 1 deletion src/ome_zarr_models/v04/well_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from ome_zarr_models._utils import _AlphaNumericConstraint, _unique_items_validator
from ome_zarr_models.base import BaseAttrs

# WellGroup is defined one level higher
__all__ = ["WellImage", "WellMeta"]


Expand Down
25 changes: 25 additions & 0 deletions tests/v05/data/well_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"ome": {
"version": "0.5",
"well": {
"images": [
{
"acquisition": 1,
"path": "0"
},
{
"acquisition": 1,
"path": "1"
},
{
"acquisition": 2,
"path": "2"
},
{
"acquisition": 2,
"path": "3"
}
]
}
}
}
20 changes: 20 additions & 0 deletions tests/v05/test_well.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from ome_zarr_models._v05.well import Well, WellAttrs
from ome_zarr_models._v05.well_types import WellImage, WellMeta
from tests.v05.conftest import json_to_zarr_group


def test_well() -> None:
zarr_group = json_to_zarr_group(json_fname="well_example.json")
ome_group = Well.from_zarr(zarr_group)
assert ome_group.ome_attributes == WellAttrs(
well=WellMeta(
images=[
WellImage(path="0", acquisition=1),
WellImage(path="1", acquisition=1),
WellImage(path="2", acquisition=2),
WellImage(path="3", acquisition=2),
],
version=None,
),
version="0.5",
)

0 comments on commit 6a3680c

Please sign in to comment.