Skip to content

Commit

Permalink
Fix imread tests (add contiguous=True when saving test data with ti…
Browse files Browse the repository at this point in the history
…fffile) (#164)

* Default value of tifffile save kwarg was changed in v2020.9.3 (breaking change)

* Check the right runtime warnings are raised by dask-image imread
  • Loading branch information
GenevieveBuckley committed Oct 22, 2020
1 parent 1322e24 commit 7d3c181
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions tests/test_dask_image/test_imread/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ def test_errs_imread(err_type, nframes):
]
)
@pytest.mark.parametrize(
"nframes, shape",
"nframes, shape, runtime_warning",
[
(1, (1, 4, 3)),
(-1, (1, 4, 3)),
(3, (1, 4, 3)),
(1, (5, 4, 3)),
(2, (5, 4, 3)),
(1, (10, 5, 4, 3)),
(5, (10, 5, 4, 3)),
(10, (10, 5, 4, 3)),
(-1, (10, 5, 4, 3)),
(1, (1, 4, 3), None),
(-1, (1, 4, 3), None),
(3, (1, 4, 3), "`nframes` larger than"),
(1, (5, 4, 3), None),
(2, (5, 4, 3), "`nframes` does not nicely divide"),
(1, (10, 5, 4, 3), None),
(5, (10, 5, 4, 3), None),
(10, (10, 5, 4, 3), None),
(-1, (10, 5, 4, 3), None),
]
)
@pytest.mark.parametrize(
Expand All @@ -57,7 +57,7 @@ def test_errs_imread(err_type, nframes):
np.float32,
]
)
def test_tiff_imread(tmpdir, seed, nframes, shape, dtype):
def test_tiff_imread(tmpdir, seed, nframes, shape, runtime_warning, dtype):
np.random.seed(seed)

dirpth = tmpdir.mkdir("test_imread")
Expand All @@ -72,9 +72,11 @@ def test_tiff_imread(tmpdir, seed, nframes, shape, dtype):
fn = str(dirpth.join("test.tiff"))
with tifffile.TiffWriter(fn) as fh:
for i in range(len(a)):
fh.save(a[i])
fh.save(a[i], contiguous=True)

d = dask_image.imread.imread(fn, nframes=nframes)
with pytest.warns(None if runtime_warning is None
else RuntimeWarning, match=runtime_warning):
d = dask_image.imread.imread(fn, nframes=nframes)

if nframes == -1:
nframes = shape[0]
Expand Down

0 comments on commit 7d3c181

Please sign in to comment.