From 04879e2226072442a4663f270900cadab382decb Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Mon, 30 Sep 2024 21:54:32 -0700 Subject: [PATCH 1/7] fix bug with mismatched row/col name case --- iohub/ngff/nodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iohub/ngff/nodes.py b/iohub/ngff/nodes.py index 6d63a8e0..2b51d3b6 100644 --- a/iohub/ngff/nodes.py +++ b/iohub/ngff/nodes.py @@ -193,7 +193,7 @@ def __delitem__(self, key): def __contains__(self, key): key = normalize_storage_path(key) - return key in self._member_names + return key.lower() in [name.lower() for name in self._member_names] def __iter__(self): yield from self._member_names From b121e57be5da0cde67948da6e265d515e365652a Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Mon, 30 Sep 2024 22:13:19 -0700 Subject: [PATCH 2/7] remove deadline for `test_apply_transform_to_zyx_and_save` and `test_process_single_position` - actually makes tests run faster --- tests/ngff/test_ngff_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ngff/test_ngff_utils.py b/tests/ngff/test_ngff_utils.py index a141ab5a..7cc0a5ca 100644 --- a/tests/ngff/test_ngff_utils.py +++ b/tests/ngff/test_ngff_utils.py @@ -498,7 +498,7 @@ def test_create_empty_plate(plate_setup, extra_channels): setup=apply_transform_czyx_setup(), constant=st.integers(min_value=1, max_value=5), ) -@settings(max_examples=5, deadline=1200) +@settings(max_examples=5, deadline=None) def test_apply_transform_to_zyx_and_save(setup, constant): ( position_keys, @@ -562,7 +562,7 @@ def test_apply_transform_to_zyx_and_save(setup, constant): constant=st.integers(min_value=1, max_value=3), num_processes=st.integers(min_value=1, max_value=3), ) -@settings(max_examples=3, deadline=2000) +@settings(max_examples=3, deadline=None) def test_process_single_position(setup, constant, num_processes): # def test_process_single_position(setup, constant, num_processes): ( From fb9e909e6759925e77eedc1bdf45bfed4ded50fb Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Mon, 30 Sep 2024 22:42:04 -0700 Subject: [PATCH 3/7] try to fix test_combine_fovs_to_hcs --- tests/ngff/test_ngff.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ngff/test_ngff.py b/tests/ngff/test_ngff.py index 50376a3a..91977c48 100644 --- a/tests/ngff/test_ngff.py +++ b/tests/ngff/test_ngff.py @@ -684,14 +684,14 @@ def test_position_scale(channels_and_random_5d): def test_combine_fovs_to_hcs(): fovs = {} fov_paths = ("A/1/0", "B/1/0", "H/12/9") - for path in fov_paths: - with open_ome_zarr(hcs_ref) as hcs_store: + with open_ome_zarr(hcs_ref) as hcs_store: + for path in fov_paths: fovs[path] = hcs_store["B/03/0"] with TemporaryDirectory() as temp_dir: store_path = os.path.join(temp_dir, "combined.zarr") - combined_plate = Plate.from_positions(store_path, fovs) + Plate.from_positions(store_path, fovs).close() # read data with an external reader - ext_reader = Reader(parse_url(combined_plate.zgroup.store.path)) + ext_reader = Reader(parse_url(store_path)) node = list(ext_reader())[0] plate_meta = node.metadata["metadata"]["plate"] assert len(plate_meta["rows"]) == 3 From 1848a912e6248b0e307742b41c103426a79f0a13 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Mon, 30 Sep 2024 23:34:54 -0700 Subject: [PATCH 4/7] skip test_combine_fovs_to_hcs --- tests/ngff/test_ngff.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ngff/test_ngff.py b/tests/ngff/test_ngff.py index 91977c48..62770d42 100644 --- a/tests/ngff/test_ngff.py +++ b/tests/ngff/test_ngff.py @@ -681,6 +681,7 @@ def test_position_scale(channels_and_random_5d): assert dataset.scale == scale +@pytest.mark.skip(reason="https://github.com/czbiohub-sf/iohub/issues/255") def test_combine_fovs_to_hcs(): fovs = {} fov_paths = ("A/1/0", "B/1/0", "H/12/9") From 53f42a14ce38bb4bfc98b0380fc2a12b008f5005 Mon Sep 17 00:00:00 2001 From: Talon Chandler Date: Wed, 2 Oct 2024 11:06:37 -0700 Subject: [PATCH 5/7] test case sensitivity --- tests/ngff/test_ngff.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/ngff/test_ngff.py b/tests/ngff/test_ngff.py index 62770d42..7ad9f2f3 100644 --- a/tests/ngff/test_ngff.py +++ b/tests/ngff/test_ngff.py @@ -16,6 +16,7 @@ from numpy.typing import NDArray from ome_zarr.io import parse_url from ome_zarr.reader import Reader +from zarr.errors import ContainsGroupError if TYPE_CHECKING: from _typeshed import StrPath @@ -630,7 +631,6 @@ def test_modify_hcs_ref(row: str, col: str, pos: str): new_pos.create_zeros("0", position[0].shape, position[0].dtype) assert not dataset[f"{new_pos_path}/0"][:].any() - @given(row_names=plate_axis_names_st, col_names=plate_axis_names_st) @settings(max_examples=16, deadline=2000) def test_create_well(row_names: list[str], col_names: list[str]): @@ -667,6 +667,20 @@ def test_create_position(row, col, pos): assert os.path.isdir(os.path.join(store_path, row, col, pos)) assert dataset[row][col].metadata.images[0].path == pos +def test_create_position_case_sensitivity(row, col, pos): + """Test `iohub.ngff.Plate.create_position()`""" + with TemporaryDirectory() as temp_dir: + store_path = os.path.join(temp_dir, "hcs.zarr") + dataset = open_ome_zarr( + store_path, layout="hcs", mode="a", channel_names=["GFP"] + ) + dataset.create_position("S", "0", "1") + dataset.create_position("s", "1", "0") + + with pytest.raises(ContainsGroupError): + dataset.create_position("S", "1", "0") + + @given(channels_and_random_5d=_channels_and_random_5d()) def test_position_scale(channels_and_random_5d): From 13c260a86d645bc153746206a56a277daf47503f Mon Sep 17 00:00:00 2001 From: Talon Chandler Date: Wed, 2 Oct 2024 11:14:09 -0700 Subject: [PATCH 6/7] fix test --- tests/ngff/test_ngff.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/ngff/test_ngff.py b/tests/ngff/test_ngff.py index 7ad9f2f3..b5720225 100644 --- a/tests/ngff/test_ngff.py +++ b/tests/ngff/test_ngff.py @@ -631,6 +631,7 @@ def test_modify_hcs_ref(row: str, col: str, pos: str): new_pos.create_zeros("0", position[0].shape, position[0].dtype) assert not dataset[f"{new_pos_path}/0"][:].any() + @given(row_names=plate_axis_names_st, col_names=plate_axis_names_st) @settings(max_examples=16, deadline=2000) def test_create_well(row_names: list[str], col_names: list[str]): @@ -667,7 +668,8 @@ def test_create_position(row, col, pos): assert os.path.isdir(os.path.join(store_path, row, col, pos)) assert dataset[row][col].metadata.images[0].path == pos -def test_create_position_case_sensitivity(row, col, pos): + +def test_create_position_case_sensitivity(): """Test `iohub.ngff.Plate.create_position()`""" with TemporaryDirectory() as temp_dir: store_path = os.path.join(temp_dir, "hcs.zarr") @@ -681,7 +683,6 @@ def test_create_position_case_sensitivity(row, col, pos): dataset.create_position("S", "1", "0") - @given(channels_and_random_5d=_channels_and_random_5d()) def test_position_scale(channels_and_random_5d): """Test `iohub.ngff.Position.scale`""" From 850b95116f1d7fe7323f0c85a04808694220073c Mon Sep 17 00:00:00 2001 From: Talon Chandler Date: Wed, 2 Oct 2024 13:30:55 -0700 Subject: [PATCH 7/7] Revert "test case sensitivity" This reverts commit 53f42a14ce38bb4bfc98b0380fc2a12b008f5005. --- tests/ngff/test_ngff.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/ngff/test_ngff.py b/tests/ngff/test_ngff.py index b5720225..62770d42 100644 --- a/tests/ngff/test_ngff.py +++ b/tests/ngff/test_ngff.py @@ -16,7 +16,6 @@ from numpy.typing import NDArray from ome_zarr.io import parse_url from ome_zarr.reader import Reader -from zarr.errors import ContainsGroupError if TYPE_CHECKING: from _typeshed import StrPath @@ -669,20 +668,6 @@ def test_create_position(row, col, pos): assert dataset[row][col].metadata.images[0].path == pos -def test_create_position_case_sensitivity(): - """Test `iohub.ngff.Plate.create_position()`""" - with TemporaryDirectory() as temp_dir: - store_path = os.path.join(temp_dir, "hcs.zarr") - dataset = open_ome_zarr( - store_path, layout="hcs", mode="a", channel_names=["GFP"] - ) - dataset.create_position("S", "0", "1") - dataset.create_position("s", "1", "0") - - with pytest.raises(ContainsGroupError): - dataset.create_position("S", "1", "0") - - @given(channels_and_random_5d=_channels_and_random_5d()) def test_position_scale(channels_and_random_5d): """Test `iohub.ngff.Position.scale`"""