Skip to content

Commit

Permalink
added zarr tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sameeul committed May 28, 2024
1 parent f9f2605 commit b44be95
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
tests/data

# Translations
*.mo
Expand Down
51 changes: 49 additions & 2 deletions tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ome_zarr.utils import download as zarr_download

TEST_IMAGES = {
"5025551.zarr": "https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0054A/5025551.zarr",
"p01_x01_y01_wx0_wy0_c1.ome.tif": "https://raw.githubusercontent.com/sameeul/polus-test-data/main/bfio/p01_x01_y01_wx0_wy0_c1.ome.tif",
"Plate1-Blue-A-12-Scene-3-P3-F2-03.czi": "https://downloads.openmicroscopy.org/images/Zeiss-CZI/idr0011/Plate1-Blue-A_TS-Stinger/Plate1-Blue-A-12-Scene-3-P3-F2-03.czi",
}
Expand Down Expand Up @@ -63,7 +64,7 @@ def tearDownModule():
"""Remove test images"""

logger.info("teardown - Removing test images...")
shutil.rmtree(TEST_DIR)
# shutil.rmtree(TEST_DIR)


class TestOmeTiffRead(unittest.TestCase):
Expand All @@ -85,7 +86,7 @@ def test_read_ome_tif_full(self):
cols = Seq(0, br._X - 1, 1)
layers = Seq(0, br._Z - 1, 1)
channels = Seq(0, br._C - 1, 1)
tsteps = Seq(0, br._Z - 1, 1)
tsteps = Seq(0, br._T - 1, 1)
tmp = br.data(rows, cols, layers, channels, tsteps)

assert tmp.dtype == np.uint16
Expand Down Expand Up @@ -201,3 +202,49 @@ def test_read_ome_tif_4d(self):

def test_read_ome_tif_5d(self):
pass


class TestOmeZarrRead(unittest.TestCase):

def test_read_zarr_2d_slice(self):
"""test_read_zarr_2d_slice - Read tiff using TSReader"""
br = TSReader(
str(TEST_DIR.joinpath("5025551.zarr/0")),
FileType.OmeZarr,
"",
)
assert br._X == 2702
assert br._Y == 2700
assert br._Z == 1
assert br._C == 27
assert br._T == 1

rows = Seq(0, br._Y - 1, 1)
cols = Seq(0, br._X - 1, 1)
layers = Seq(0, 0, 1)
channels = Seq(0, 0, 1)
tsteps = Seq(0, 0, 1)
tmp = br.data(rows, cols, layers, channels, tsteps)

assert tmp.dtype == np.uint8
assert tmp.sum() == 183750394
assert tmp.shape == (1, 1, 1, 2700, 2702)

def test_read_zarr_4d_slice(self):
"""test_read_zarr_4d_slice - Read tiff using TSReader"""
br = TSReader(
str(TEST_DIR.joinpath("5025551.zarr/0")),
FileType.OmeZarr,
"",
)

rows = Seq(0, 1023, 1)
cols = Seq(0, 1023, 1)
layers = Seq(0, 0, 1)
channels = Seq(0, 3, 1)
tsteps = Seq(0, 0, 1)
tmp = br.data(rows, cols, layers, channels, tsteps)

assert tmp.dtype == np.uint8
assert tmp.sum() == 81778531
assert tmp.shape == (1, 4, 1, 1024, 1024)

0 comments on commit b44be95

Please sign in to comment.