Skip to content

Commit

Permalink
fix minor issues with type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzocerrone committed Oct 31, 2024
1 parent 7d9abf6 commit 942ed0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/ngio/ngff_meta/fractal_image_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ class PixelSize(BaseModel):
unit: SpaceUnits = SpaceUnits.micrometer
virtual: bool = False

def __repr__(self):
def __repr__(self) -> str:
"""Return the string representation of the object."""
return f"PixelSize(x={self.x}, y={self.y}, z={self.z}, unit={self.unit.value})"

@classmethod
def from_list(cls, sizes: list[float], unit: SpaceUnits):
def from_list(cls, sizes: list[float], unit: SpaceUnits) -> "PixelSize":
"""Build a PixelSize object from a list of sizes.
Note: The order of the sizes must be z, y, x.
Expand Down Expand Up @@ -262,7 +262,7 @@ def unit(self) -> SpaceUnits | TimeUnits | None:
return self._unit

@unit.setter
def unit(self, unit: SpaceUnits | TimeUnits | None):
def unit(self, unit: SpaceUnits | TimeUnits | None) -> None:
"""Set the unit of the axis."""
self._unit = unit

Expand Down Expand Up @@ -826,7 +826,7 @@ def __init__(self, version: str, name: str, datasets: list[Dataset]) -> None:

def add_axis(
self, axis_name: str, scale: float = 1, translation: float | None = None
) -> BaseMeta:
) -> "LabelMeta":
"""Add an axis to the metadata."""
# Check if the axis is a channel
axis = Axis.lazy_create(
Expand All @@ -837,9 +837,10 @@ def add_axis(
if axis.type == AxisType.channel:
raise ValueError("Channel axes are not allowed in LabelMeta.")

return super().add_axis(
meta = super().add_axis(
axis_name=axis_name, scale=scale, translation=translation
)
return meta


class ImageMeta(BaseMeta):
Expand All @@ -866,6 +867,8 @@ def channels(self) -> list[Channel]:
"""Get the channels in the image."""
if self._omero is None:
return []
assert self.omero is not None
assert self.omero.channels is not None
return self.omero.channels

@property
Expand Down
5 changes: 3 additions & 2 deletions src/ngio/pipes/_zomm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def _numpy_zoom(
out_array = zoom(
source_array, zoom=_scale, order=order, mode="grid-constant", grid_mode=True
)
assert isinstance(out_array, np.ndarray)
return out_array


Expand All @@ -119,7 +120,7 @@ def on_disk_zoom(
target: zarr.Array,
order: Literal[0, 1, 2] = 1,
mode: Literal["dask", "numpy"] = "dask",
):
) -> None:
"""Apply a zoom operation from a source zarr array to a target zarr array.
Args:
Expand Down Expand Up @@ -154,7 +155,7 @@ def on_disk_coarsen(
target: zarr.Array,
aggregation_function: np.ufunc,
coarsening_setup: dict[int, int],
):
) -> None:
"""Apply a coarsening operation from a source zarr array to a target zarr array.
Args:
Expand Down

0 comments on commit 942ed0e

Please sign in to comment.