ngio 0.2.7__py3-none-any.whl → 0.2.8__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.
@@ -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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngio
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Next Generation file format IO
5
5
  Project-URL: homepage, https://github.com/lorenzocerrone/ngio
6
6
  Project-URL: repository, https://github.com/lorenzocerrone/ngio
@@ -22,7 +22,7 @@ ngio/ome_zarr_meta/__init__.py,sha256=oZ8PEsWM7U0KwzpsnvVfX9k4UfuTz5sZ8B6B9eY5hy
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
24
  ngio/ome_zarr_meta/ngio_specs/_axes.py,sha256=Kqe9T7LWa_9o3UWS5uzALyyNluIhXxWhDGxWY4-GIo8,16707
25
- ngio/ome_zarr_meta/ngio_specs/_channels.py,sha256=piK_SZ1Oay2_f2Sq4BFMOadMYc2yI1itfH075qxFznc,14085
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.7.dist-info/METADATA,sha256=DI47tFwc8OP-d0nuqNHv4pSUhg15pJiU2uUDmiq9Q-U,5215
55
- ngio-0.2.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
- ngio-0.2.7.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
57
- ngio-0.2.7.dist-info/RECORD,,
54
+ ngio-0.2.8.dist-info/METADATA,sha256=Rf7imDRysf67wo02l22A8DX2TjeWQLndDdzPp48YncY,5215
55
+ ngio-0.2.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
+ ngio-0.2.8.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
57
+ ngio-0.2.8.dist-info/RECORD,,
File without changes