ngio 0.2.7__py3-none-any.whl → 0.2.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ngio/ome_zarr_meta/ngio_specs/_axes.py +4 -7
- ngio/ome_zarr_meta/ngio_specs/_channels.py +28 -2
- {ngio-0.2.7.dist-info → ngio-0.2.9.dist-info}/METADATA +1 -1
- {ngio-0.2.7.dist-info → ngio-0.2.9.dist-info}/RECORD +6 -6
- {ngio-0.2.7.dist-info → ngio-0.2.9.dist-info}/WHEEL +0 -0
- {ngio-0.2.7.dist-info → ngio-0.2.9.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from collections.abc import Collection
|
|
4
4
|
from enum import Enum
|
|
5
|
-
from logging import Logger
|
|
6
5
|
from typing import Literal, TypeVar
|
|
7
6
|
|
|
8
7
|
import numpy as np
|
|
9
8
|
from pydantic import BaseModel, ConfigDict, Field
|
|
10
9
|
|
|
11
|
-
from ngio.utils import NgioValidationError, NgioValueError
|
|
12
|
-
|
|
13
|
-
logger = Logger(__name__)
|
|
10
|
+
from ngio.utils import NgioValidationError, NgioValueError, ngio_logger
|
|
14
11
|
|
|
15
12
|
T = TypeVar("T")
|
|
16
13
|
|
|
@@ -102,20 +99,20 @@ class Axis(BaseModel):
|
|
|
102
99
|
def implicit_type_cast(self, cast_type: AxisType) -> "Axis":
|
|
103
100
|
unit = self.unit
|
|
104
101
|
if self.axis_type != cast_type:
|
|
105
|
-
|
|
102
|
+
ngio_logger.warning(
|
|
106
103
|
f"Axis {self.on_disk_name} has type {self.axis_type}. "
|
|
107
104
|
f"Casting to {cast_type}."
|
|
108
105
|
)
|
|
109
106
|
|
|
110
107
|
if cast_type == AxisType.time and unit is None:
|
|
111
|
-
|
|
108
|
+
ngio_logger.warning(
|
|
112
109
|
f"Time axis {self.on_disk_name} has unit {self.unit}. "
|
|
113
110
|
f"Casting to {DefaultSpaceUnit}."
|
|
114
111
|
)
|
|
115
112
|
unit = DefaultTimeUnit
|
|
116
113
|
|
|
117
114
|
if cast_type == AxisType.space and unit is None:
|
|
118
|
-
|
|
115
|
+
ngio_logger.warning(
|
|
119
116
|
f"Space axis {self.on_disk_name} has unit {unit}. "
|
|
120
117
|
f"Casting to {DefaultSpaceUnit}."
|
|
121
118
|
)
|
|
@@ -9,7 +9,7 @@ from enum import Enum
|
|
|
9
9
|
from typing import Any, TypeVar
|
|
10
10
|
|
|
11
11
|
import numpy as np
|
|
12
|
-
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
12
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
|
13
13
|
|
|
14
14
|
from ngio.utils import NgioValidationError, NgioValueError
|
|
15
15
|
|
|
@@ -124,7 +124,6 @@ class ChannelVisualisation(BaseModel):
|
|
|
124
124
|
model_config = ConfigDict(extra="allow", frozen=True)
|
|
125
125
|
|
|
126
126
|
@field_validator("color", mode="after")
|
|
127
|
-
@classmethod
|
|
128
127
|
def validate_color(cls, value: str | NgioColors) -> str:
|
|
129
128
|
"""Color validator.
|
|
130
129
|
|
|
@@ -145,6 +144,33 @@ class ChannelVisualisation(BaseModel):
|
|
|
145
144
|
else:
|
|
146
145
|
raise NgioValueError(f"Invalid color {value}.")
|
|
147
146
|
|
|
147
|
+
@model_validator(mode="before")
|
|
148
|
+
def check_start_end(cls, data):
|
|
149
|
+
"""Check that the start and end values are valid.
|
|
150
|
+
|
|
151
|
+
If the start and end values are equal, set the end value to start + 1
|
|
152
|
+
"""
|
|
153
|
+
start = data.get("start", None)
|
|
154
|
+
end = data.get("end", None)
|
|
155
|
+
if start is None or end is None:
|
|
156
|
+
return data
|
|
157
|
+
if abs(end - start) < 1e-6:
|
|
158
|
+
data["end"] = start + 1
|
|
159
|
+
return data
|
|
160
|
+
|
|
161
|
+
@model_validator(mode="after")
|
|
162
|
+
def check_model(self) -> "ChannelVisualisation":
|
|
163
|
+
"""Check that the start and end values are within the min and max values."""
|
|
164
|
+
if self.start < self.min or self.start > self.max:
|
|
165
|
+
raise NgioValidationError(
|
|
166
|
+
f"Start value {self.start} is out of range [{self.min}, {self.max}]"
|
|
167
|
+
)
|
|
168
|
+
if self.end < self.min or self.end > self.max:
|
|
169
|
+
raise NgioValidationError(
|
|
170
|
+
f"End value {self.end} is out of range [{self.min}, {self.max}]"
|
|
171
|
+
)
|
|
172
|
+
return self
|
|
173
|
+
|
|
148
174
|
@classmethod
|
|
149
175
|
def default_init(
|
|
150
176
|
cls,
|
|
@@ -21,8 +21,8 @@ ngio/images/ome_zarr_container.py,sha256=-9bbzNtsVAjU1X_h78Lr5LOV0JXtOiWVWqmt3DF
|
|
|
21
21
|
ngio/ome_zarr_meta/__init__.py,sha256=oZ8PEsWM7U0KwzpsnvVfX9k4UfuTz5sZ8B6B9eY5hyY,1193
|
|
22
22
|
ngio/ome_zarr_meta/_meta_handlers.py,sha256=BLvYt5PONYrWkEb2XgEiAXR_OX9rfeX_C0eEqen0jQA,25549
|
|
23
23
|
ngio/ome_zarr_meta/ngio_specs/__init__.py,sha256=05NQukZG0nNvjzf8AKWGu7PhjhQcImGSAOK3D3Bg-Js,1786
|
|
24
|
-
ngio/ome_zarr_meta/ngio_specs/_axes.py,sha256=
|
|
25
|
-
ngio/ome_zarr_meta/ngio_specs/_channels.py,sha256=
|
|
24
|
+
ngio/ome_zarr_meta/ngio_specs/_axes.py,sha256=tHtx6NfBgDcCgDk9CosjIjw1KZJ2qi0i_eoLgrdiEWw,16681
|
|
25
|
+
ngio/ome_zarr_meta/ngio_specs/_channels.py,sha256=2L-HM9K1Xu4qRI2MiXPqgCuHdCBRydEW1StThcqEuvY,15120
|
|
26
26
|
ngio/ome_zarr_meta/ngio_specs/_dataset.py,sha256=hY8ogPPxvCgVg6k02t3zUr24lasYrvnxBd1iPEigdG4,5892
|
|
27
27
|
ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py,sha256=uh345KQmEQtslIyMmLK9sB-NbjPYxi0Y9FuYIFhd3Rc,17465
|
|
28
28
|
ngio/ome_zarr_meta/ngio_specs/_ngio_image.py,sha256=8E38Mgw-l0Ff1nkmCJIzo64G_paAVhM8xktUS_V5egY,17960
|
|
@@ -51,7 +51,7 @@ ngio/utils/_errors.py,sha256=pKQ12LUjQLYE1nUawemA5h7HsgznjaSvV1n2PQU33N0,759
|
|
|
51
51
|
ngio/utils/_fractal_fsspec_store.py,sha256=7qoGLiLi8JQFh9Ej_z5WNwQQuWrujb0f6p9nj8ocsS8,548
|
|
52
52
|
ngio/utils/_logger.py,sha256=HIuqD_2ShfFGDswBddcouStbKfL0Vz_ah8cAIFGhbS8,888
|
|
53
53
|
ngio/utils/_zarr_utils.py,sha256=qOI-HL2HsfFLCj_yxsTR-aq4oHpSqS9KR13aEIvhGDY,13593
|
|
54
|
-
ngio-0.2.
|
|
55
|
-
ngio-0.2.
|
|
56
|
-
ngio-0.2.
|
|
57
|
-
ngio-0.2.
|
|
54
|
+
ngio-0.2.9.dist-info/METADATA,sha256=3hSjDhHlP2G3U8g1HcTNO5bQWGBEB0S1FLSMwDh4RlQ,5215
|
|
55
|
+
ngio-0.2.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
56
|
+
ngio-0.2.9.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
|
|
57
|
+
ngio-0.2.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|