From 75b9eeca5e1b55548e64787802a68fec7302ee3a Mon Sep 17 00:00:00 2001 From: lorenzo Date: Wed, 13 Nov 2024 17:49:03 +0100 Subject: [PATCH] expand testing --- tests/core/test_image_handler.py | 6 +++- tests/core/test_label_handler.py | 1 + tests/tables/test_table_group.py | 5 ++- tests/tables/test_v1_tables.py | 55 ++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 tests/tables/test_v1_tables.py diff --git a/tests/core/test_image_handler.py b/tests/core/test_image_handler.py index d729a67..a90a985 100644 --- a/tests/core/test_image_handler.py +++ b/tests/core/test_image_handler.py @@ -1,10 +1,14 @@ +from pathlib import Path + + class TestImageHandler: - def test_ngff_image(self, ome_zarr_image_v04_path): + def test_ngff_image(self, ome_zarr_image_v04_path: Path) -> None: import numpy as np from ngio.core.image_handler import Image image_handler = Image(store=ome_zarr_image_v04_path, path="0") + image_handler.__repr__() assert image_handler.array_path == f"{ome_zarr_image_v04_path}/0" assert image_handler.channel_labels == ["DAPI", "nanog", "Lamin B1"] diff --git a/tests/core/test_label_handler.py b/tests/core/test_label_handler.py index d71ec36..8e5805e 100644 --- a/tests/core/test_label_handler.py +++ b/tests/core/test_label_handler.py @@ -11,6 +11,7 @@ def test_label_image(self, ome_zarr_image_v04_path: Path) -> None: ngff_image = NgffImage(ome_zarr_image_v04_path) image_handler = ngff_image.get_image(path="0") label_handler = ngff_image.label.derive(name="label") + label_handler.__repr__() assert label_handler.array_path == f"{ome_zarr_image_v04_path}/labels/label/0" assert ngff_image.label.list() == ["label"] diff --git a/tests/tables/test_table_group.py b/tests/tables/test_table_group.py index 704e40b..7775079 100644 --- a/tests/tables/test_table_group.py +++ b/tests/tables/test_table_group.py @@ -1,5 +1,8 @@ +from pathlib import Path + + class TestTableGroup: - def test_table_group(self, ome_zarr_image_v04_path): + def test_table_group(self, ome_zarr_image_v04_path: Path) -> None: from ngio.core.ngff_image import NgffImage ngff_image = NgffImage(ome_zarr_image_v04_path) diff --git a/tests/tables/test_v1_tables.py b/tests/tables/test_v1_tables.py new file mode 100644 index 0000000..9513ea5 --- /dev/null +++ b/tests/tables/test_v1_tables.py @@ -0,0 +1,55 @@ +from pathlib import Path + + +class TestTables: + def test_roi_table(self, ome_zarr_image_v04_path: Path) -> None: + from ngio.core.ngff_image import NgffImage + from ngio.core.roi import WorldCooROI + + ngff_image = NgffImage(ome_zarr_image_v04_path) + + roi_table = ngff_image.table.new( + name="roi_table", + table_type="roi_table", + overwrite=False, + ) + roi_table.__repr__() + roi_table.set_rois( + [ + WorldCooROI( + x=0, + y=0, + z=0, + x_length=10, + y_length=10, + z_length=10, + infos={"FieldIndex": "FOV1"}, + ) + ] + ) + + def test_masking_roi_table(self, ome_zarr_image_v04_path: Path) -> None: + from ngio.core.ngff_image import NgffImage + + ngff_image = NgffImage(ome_zarr_image_v04_path) + + masking_roi_table = ngff_image.table.new( + name="masking_roi_table", + table_type="masking_roi_table", + label_image="region", + overwrite=False, + ) + masking_roi_table.__repr__() + + def test_feature_table(self, ome_zarr_image_v04_path: Path) -> None: + from ngio.core.ngff_image import NgffImage + + ngff_image = NgffImage(ome_zarr_image_v04_path) + + feature_table = ngff_image.table.new( + name="feat_table", + table_type="feature_table", + label_image="region", + overwrite=True, + ) + feature_table.__repr__()