-
Notifications
You must be signed in to change notification settings - Fork 19
Changes to RFC4 #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes to RFC4 #264
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,38 @@ | ||
| from collections.abc import Sequence | ||
| from typing import Literal | ||
| from typing import Self | ||
|
|
||
| from pydantic import BaseModel, JsonValue, model_validator | ||
|
|
||
| from ome_zarr_models.common.axes import Axis as BaseAxis | ||
| from ome_zarr_models.common.axes import AxisType | ||
|
|
||
| __all__ = ["Axes", "Axis", "AxisType"] | ||
|
|
||
|
|
||
| Orientation = Literal[ | ||
| "left-to-right", | ||
| "right-to-left", | ||
| "anterior-to-posterior", | ||
| "posterior-to-anterior", | ||
| "inferior-to-superior", | ||
| "superior-to-inferior", | ||
| "dorsal-to-ventral", | ||
| "ventral-to-dorsal", | ||
| "dorsal-to-palmar", | ||
| "palmar-to-dorsal", | ||
| "dorsal-to-plantar", | ||
| "plantar-to-dorsal", | ||
| "rostral-to-caudal", | ||
| "caudal-to-rostral", | ||
| "cranial-to-caudal", | ||
| "caudal-to-cranial", | ||
| "proximal-to-distal", | ||
| "distal-to-proximal", | ||
| ] | ||
| class Orientation(BaseModel): | ||
| """ | ||
| Model for an orientation object. | ||
| """ | ||
|
|
||
| type: JsonValue | ||
| value: JsonValue | ||
|
|
||
|
|
||
| class Axis(BaseAxis): | ||
| """ | ||
| Model for an element of multiscale axes. | ||
| Model for an element of `Multiscale.axes`. | ||
| """ | ||
|
|
||
| anatomicalOrientation: Orientation | None = None | ||
| orientation: Orientation | None = None | ||
|
|
||
| @model_validator(mode="after") | ||
| def _check_orientation_only_on_spatial(self) -> Self: | ||
| if self.type != "space" and self.orientation is not None: | ||
| raise ValueError( | ||
| f"Orientation can only be set on a spatial axis " | ||
| f"(got Axis type='{self.type}')" | ||
| ) | ||
| return self | ||
|
|
||
|
|
||
| Axes = Sequence[Axis] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import pytest | ||
| from pydantic import ValidationError | ||
|
|
||
| from ome_zarr_models._v06.axes import Axis | ||
|
|
||
|
|
||
| def test_orientation_only_spatial() -> None: | ||
| with pytest.raises( | ||
| ValidationError, match="Orientation can only be set on a spatial axis" | ||
| ): | ||
| Axis( | ||
| name="my_axis", | ||
| type="time", | ||
| orientation={"type": "anatomical", "value": "anterior-to-posterior"}, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.