- make zstd block include content size so fiji can actually read it
- add compression level argument - remove shape argument - some more pytest tests
This commit is contained in:
@@ -12,7 +12,7 @@ def test_mult(tmp_path: Path) -> None:
|
||||
shape = (2, 3, 5)
|
||||
paths = [tmp_path / f'test{i}.tif' for i in range(6)]
|
||||
with ExitStack() as stack:
|
||||
tifs = [stack.enter_context(IJTiffFile(path, shape)) for path in paths] # noqa
|
||||
tifs = [stack.enter_context(IJTiffFile(path)) for path in paths] # noqa
|
||||
for c, z, t in tqdm(product(range(shape[0]), range(shape[1]), range(shape[2])), total=np.prod(shape)): # noqa
|
||||
for tif in tifs:
|
||||
tif.save(np.random.randint(0, 255, (64, 64)), c, z, t)
|
||||
|
||||
@@ -1,14 +1,28 @@
|
||||
from itertools import product
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
from tifffile import imread
|
||||
|
||||
from tiffwrite import IJTiffFile
|
||||
|
||||
|
||||
def test_single(tmp_path: Path) -> None:
|
||||
path = tmp_path / 'test.tif'
|
||||
with IJTiffFile(path, (3, 4, 5)) as tif:
|
||||
for c, z, t in product(range(3), range(4), range(5)):
|
||||
tif.save(np.random.randint(0, 255, (64, 64)), c, z, t)
|
||||
assert path.exists()
|
||||
@pytest.mark.parametrize('dtype', ('uint8', 'uint16', 'uint32', 'uint64',
|
||||
'int8', 'int16', 'int32', 'int64', 'float32', 'float64'))
|
||||
def test_single(tmp_path: Path, dtype) -> None:
|
||||
with IJTiffFile(tmp_path / 'test.tif', dtype=dtype) as tif:
|
||||
a0, b0 = np.meshgrid(range(100), range(100))
|
||||
a0[::2, :] = 0
|
||||
b0[:, ::2] = 1
|
||||
tif.save(a0, 0, 0, 0)
|
||||
tif.save(b0, 1, 0, 0)
|
||||
|
||||
a1, b1 = np.meshgrid(range(100), range(100))
|
||||
a1[:, ::2] = 0
|
||||
b1[::2, :] = 1
|
||||
tif.save(a1, 0, 0, 1)
|
||||
tif.save(b1, 1, 0, 1)
|
||||
|
||||
t = imread(tmp_path / 'test.tif')
|
||||
assert t.dtype == np.dtype(dtype), "data type does not match"
|
||||
assert np.all(np.stack(((a0, b0), (a1, b1))) == t), "data does not match"
|
||||
|
||||
Reference in New Issue
Block a user