diff --git a/tests/conftest.py b/tests/conftest.py index 198e51ac..3b0c9327 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,13 +1,23 @@ +from __future__ import annotations +from typing import TYPE_CHECKING from pathlib import Path import numpy as np from iohub import open_ome_zarr from pytest import TempPathFactory, fixture +if TYPE_CHECKING: + from numpy.typing import DTypeLike + channel_names = ["Phase", "Retardance", "GFP", "DAPI"] -def _build_hcs(path: Path, channel_names: list[str], zyx_shape: tuple[int, int, int]): +def _build_hcs( + path: Path, + channel_names: list[str], + zyx_shape: tuple[int, int, int], + dtype: DTypeLike, +): dataset = open_ome_zarr( path, layout="hcs", @@ -20,9 +30,7 @@ def _build_hcs(path: Path, channel_names: list[str], zyx_shape: tuple[int, int, pos = dataset.create_position(row, col, fov) pos.create_image( "0", - np.random.rand(2, len(channel_names), *zyx_shape).astype( - np.float32 - ), + np.random.rand(2, len(channel_names), *zyx_shape).astype(dtype), ) @@ -30,7 +38,7 @@ def _build_hcs(path: Path, channel_names: list[str], zyx_shape: tuple[int, int, def preprocessed_hcs_dataset(tmp_path_factory: TempPathFactory) -> Path: """Provides a preprocessed HCS OME-Zarr dataset.""" dataset_path = tmp_path_factory.mktemp("preprocessed.zarr") - _build_hcs(dataset_path, channel_names, (12, 256, 256)) + _build_hcs(dataset_path, channel_names, (12, 256, 256), np.float32) # U[0, 1) expected = {"mean": 0.5, "std": 1 / np.sqrt(12), "median": 0.5, "iqr": 0.5} norm_meta = {channel: {"dataset_statistics": expected} for channel in channel_names} @@ -45,5 +53,5 @@ def preprocessed_hcs_dataset(tmp_path_factory: TempPathFactory) -> Path: def small_hcs_dataset(tmp_path_factory: TempPathFactory) -> Path: """Provides a small, not preprocessed HCS OME-Zarr dataset.""" dataset_path = tmp_path_factory.mktemp("small.zarr") - _build_hcs(dataset_path, channel_names, (12, 64, 64)) + _build_hcs(dataset_path, channel_names, (12, 64, 64), np.uint16) return dataset_path