-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from annshress/add_tests
Update tests for hedwingZarrImage.zarr_rechunk
- Loading branch information
Showing
4 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
pytest>=6.0 | ||
ome_zarr | ||
-rrequirements.txt | ||
setuptools_scm | ||
flake8 | ||
black | ||
wheel | ||
packaging | ||
-r requirements.txt |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
from click.testing import CliRunner | ||
import pytools.zarr_rechunk | ||
import shutil | ||
from pathlib import Path | ||
import pytest | ||
import pytools.zarr_rechunk | ||
from pytools.HedwigZarrImages import HedwigZarrImages | ||
|
||
args = ["--help", "--version"] | ||
|
||
|
||
@pytest.mark.parametrize("cli_args", args) | ||
def test_mrc2nifti_main_help(cli_args): | ||
def test_zarr_rechunk_main_help(cli_args): | ||
runner = CliRunner() | ||
result = runner.invoke(pytools.zarr_rechunk.main, cli_args.split()) | ||
assert not result.exception | ||
|
||
|
||
@pytest.mark.parametrize("chunk_size", [512, 64]) | ||
def test_zarr_rechunk_main(image_ome_ngff, chunk_size): | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
local_path = image_ome_ngff.name | ||
shutil.copytree(image_ome_ngff, local_path) | ||
|
||
result = runner.invoke(pytools.zarr_rechunk.main, args=[str(local_path), "--chunk-size", chunk_size]) | ||
assert not result.exception | ||
|
||
zi = HedwigZarrImages(Path(local_path).absolute(), read_only=False) | ||
for k, hzi in zi.series(): | ||
for level in range(len(hzi._ome_ngff_multiscales()["datasets"])): | ||
arr = hzi._ome_ngff_multiscale_get_array(level) | ||
# check for expected chunking | ||
for s, c, d in zip(arr.shape, arr.chunks, hzi._ome_ngff_multiscale_dims()): | ||
if d == "T": | ||
assert s == 1 | ||
elif d == "C" or s < chunk_size: | ||
assert s == c | ||
else: | ||
assert c == chunk_size |