Skip to content

Commit

Permalink
docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jul 17, 2024
1 parent e1079f8 commit 9f7e578
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/depiction/image/multi_channel_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@


class MultiChannelImage:
"""Represents a multi-channel 2D image, internally backed by a `xarray.DataArray`."""

def __init__(self, data: DataArray) -> None:
self._data = data.transpose("y", "x", "c")
if "bg_value" not in self._data.attrs:
Expand Down Expand Up @@ -45,16 +47,17 @@ def n_channels(self) -> int:

@property
def dtype(self) -> np.dtype:
"""Returns the data type of the values."""
"""The data type of the values."""
return self._data.dtype

@property
def bg_value(self) -> int | float:
"""Returns the background value."""
"""The background value."""
return self._data.attrs["bg_value"]

@cached_property
def bg_mask(self) -> DataArray:
"""A boolean mask indicating the background values as `True` and non-background values as `False`."""
return ((self._data == self.bg_value) | (self._data.isnull() & np.isnan(self.bg_value))).all(dim="c")

@property
Expand Down

0 comments on commit 9f7e578

Please sign in to comment.