Skip to content

Commit

Permalink
Add optional resolution level checks
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanLeRoy committed Dec 5, 2023
1 parent 0a47018 commit c2fbc48
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bioio_base/image_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ def current_scene_index(self) -> int:
def set_scene(self, scene_id: Union[str, int]) -> None:
pass

@property
@abstractmethod
def resolution_levels(self) -> Tuple[int, ...]:
pass

@property
@abstractmethod
def current_resolution_level(self) -> int:
pass

@abstractmethod
def set_resolution_level(self, resolution_level: int) -> None:
pass

@property
@abstractmethod
def xarray_dask_data(self) -> xr.DataArray:
Expand Down
16 changes: 16 additions & 0 deletions bioio_base/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def run_image_container_checks(
Optional[float], Optional[float], Optional[float]
],
expected_metadata_type: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]],
set_resolution_level: int = 0,
expected_current_resolution_level: int = 0,
expected_resolution_levels: Tuple[int, ...] = (0,),
) -> ImageContainer:
"""
A general suite of tests to run against readers.
Expand All @@ -82,6 +85,13 @@ def run_image_container_checks(
assert image_container.scenes == expected_scenes
assert image_container.current_scene == expected_current_scene

# Set resolution level
image_container.set_resolution_level(set_resolution_level)

# Check resolution level info
assert image_container.resolution_levels == expected_resolution_levels
assert image_container.current_resolution_level == expected_current_resolution_level

# Check basics
assert image_container.shape == expected_shape
assert image_container.dtype == expected_dtype
Expand Down Expand Up @@ -158,6 +168,9 @@ def run_image_file_checks(
Optional[float], Optional[float], Optional[float]
],
expected_metadata_type: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]],
set_resolution_level: int = 0,
expected_current_resolution_level: int = 0,
expected_resolution_levels: Tuple[int, ...] = (0,),
) -> ImageContainer:
# Init container
image_container = ImageContainer(image, fs_kwargs=dict(anon=True))
Expand All @@ -169,8 +182,11 @@ def run_image_file_checks(
run_image_container_checks(
image_container=image_container,
set_scene=set_scene,
set_resolution_level=set_resolution_level,
expected_scenes=expected_scenes,
expected_current_scene=expected_current_scene,
expected_resolution_levels=expected_resolution_levels,
expected_current_resolution_level=expected_current_resolution_level,
expected_shape=expected_shape,
expected_dtype=expected_dtype,
expected_dims_order=expected_dims_order,
Expand Down

0 comments on commit c2fbc48

Please sign in to comment.