diff --git a/aicsimageio/readers/bfio_reader.py b/aicsimageio/readers/bfio_reader.py index 12b344142..7b9f00bd8 100644 --- a/aicsimageio/readers/bfio_reader.py +++ b/aicsimageio/readers/bfio_reader.py @@ -181,8 +181,7 @@ def set_scene(self, scene_id: Union[str, int]) -> None: "Scene id: Cannot change scene for " + f"{self.__class__.__name__} objects." ) - - else: + elif scene_id is not None: raise TypeError( f"Must provide either a string (for scene id) " f"or integer (for scene index). Provided: {scene_id} ({type(scene_id)}." diff --git a/aicsimageio/tests/image_container_test_utils.py b/aicsimageio/tests/image_container_test_utils.py index 9b71c1594..60b7aaeb2 100644 --- a/aicsimageio/tests/image_container_test_utils.py +++ b/aicsimageio/tests/image_container_test_utils.py @@ -29,6 +29,13 @@ def check_can_serialize_image_container( image_container: Union[AICSImage, Reader] ) -> None: # Dump and reconstruct + try: + from aicsimageio.readers.bfio_reader import OmeTiledTiffReader + + if isinstance(image_container, OmeTiledTiffReader): # can't be serialized + return + except ImportError: + pass reconstructed = deserialize(*serialize(image_container)) # Assert primary attrs are equal @@ -68,16 +75,32 @@ def run_image_container_checks( image_container.set_scene(set_scene) # Check scene info - assert image_container.scenes == expected_scenes - assert image_container.current_scene == expected_current_scene + assert ( + image_container.scenes == expected_scenes + ), f"{image_container.scenes} != {expected_scenes}" + assert ( + image_container.current_scene == expected_current_scene + ), f"{image_container.current_scene} != {expected_current_scene}" # Check basics - assert image_container.shape == expected_shape - assert image_container.dtype == expected_dtype - assert image_container.dims.order == expected_dims_order - assert image_container.dims.shape == expected_shape - assert image_container.channel_names == expected_channel_names - assert image_container.physical_pixel_sizes == expected_physical_pixel_sizes + assert ( + image_container.shape == expected_shape + ), f"{image_container.shape} != {expected_shape}" + assert ( + image_container.dtype == expected_dtype + ), f"{image_container.dtype} != {expected_dtype}" + assert ( + image_container.dims.order == expected_dims_order + ), f"{image_container.dims.order} != {expected_dims_order}" + assert ( + image_container.dims.shape == expected_shape + ), f"{image_container.dims} != {expected_shape}" + assert ( + image_container.channel_names == expected_channel_names + ), f"{image_container.channel_names} != {expected_channel_names}" + assert ( + image_container.physical_pixel_sizes == expected_physical_pixel_sizes + ), f"{image_container.physical_pixel_sizes} != {expected_physical_pixel_sizes}" assert isinstance(image_container.metadata, expected_metadata_type) # Read different chunks diff --git a/aicsimageio/tests/readers/extra_readers/test_bioformats_reader.py b/aicsimageio/tests/readers/extra_readers/test_bioformats_reader.py index c19d46a12..323ffac96 100644 --- a/aicsimageio/tests/readers/extra_readers/test_bioformats_reader.py +++ b/aicsimageio/tests/readers/extra_readers/test_bioformats_reader.py @@ -203,7 +203,7 @@ (1, 3, 1, 1024, 1024), np.uint16, dimensions.DEFAULT_DIMENSION_ORDER, - ["Channel:0:0", "Channel:0:1", "Channel:0:2"], + ["Red", "Green", "Blue"], (0.001, 1.2059374999999999, 1.2059570312500014), ), ( @@ -508,7 +508,7 @@ def test_bioformats_dask_tiling_read(filename: str) -> None: (1, 3, 1, 1024, 1024), np.uint16, dimensions.DEFAULT_DIMENSION_ORDER, - ["Channel:0:0", "Channel:0:1", "Channel:0:2"], + ["Red", "Green", "Blue"], (0.001, 1.2059374999999999, 1.2059570312500014), OME, ), diff --git a/aicsimageio/tests/readers/extra_readers/test_ome_tiled_tiff_reader.py b/aicsimageio/tests/readers/extra_readers/test_ome_tiled_tiff_reader.py index 7585b9c18..086d4462e 100644 --- a/aicsimageio/tests/readers/extra_readers/test_ome_tiled_tiff_reader.py +++ b/aicsimageio/tests/readers/extra_readers/test_ome_tiled_tiff_reader.py @@ -46,19 +46,6 @@ [f"C:{i}" for i in range(10)], # This is the actual metadata (None, None, None), ), - pytest.param( - # This is the same file as the first file, but it is not tiled - # This should throw and error since it is not tiled - "s_1_t_1_c_1_z_1.ome.tiff", - None, - None, - None, - None, - None, - None, - None, - marks=pytest.mark.xfail(raises=exceptions.UnsupportedFileFormatError), - ), pytest.param( "example.txt", None, @@ -70,17 +57,6 @@ None, marks=pytest.mark.xfail(raises=exceptions.UnsupportedFileFormatError), ), - pytest.param( - "s_1_t_1_c_2_z_1.lif", - None, - None, - None, - None, - None, - None, - None, - marks=pytest.mark.xfail(raises=exceptions.UnsupportedFileFormatError), - ), ], ) def test_ome_tiff_reader( diff --git a/aicsimageio/tests/readers/test_glob_reader.py b/aicsimageio/tests/readers/test_glob_reader.py index 3b105b42b..f374d8386 100644 --- a/aicsimageio/tests/readers/test_glob_reader.py +++ b/aicsimageio/tests/readers/test_glob_reader.py @@ -21,10 +21,7 @@ def check_values( ) -> None: for i, s in enumerate(reader.scenes): reader.set_scene(s) - assert np.all( - reference.isel(S=i).data == reader.xarray_dask_data.data - ).compute() - assert np.all(reference.isel(S=i).data == reader.xarray_data.data) + np.testing.assert_array_equal(reference.isel(S=i).data, reader.xarray_data.data) def make_fake_data_2d(path: Path, as_mm: bool = False) -> xr.DataArray: diff --git a/setup.py b/setup.py index cb3acc185..9c9242377 100644 --- a/setup.py +++ b/setup.py @@ -106,7 +106,7 @@ def run(self): "fsspec>=2022.8.0,<2023.9.0", "imagecodecs>=2020.5.30", "lxml>=4.6,<5", - "numpy>=1.21.0", + "numpy>=1.21.0,<2", "ome-types>=0.3.4", "ome-zarr>=0.6.1", "PyYAML>=6.0",