- Use parfor to take care of the parallel part.

- Use sha1 hash because it's consistent between processes.
This commit is contained in:
Wim Pomp
2023-09-11 17:12:04 +02:00
parent f68afd0a1b
commit e736770512
5 changed files with 80 additions and 249 deletions

View File

@@ -1,16 +1,17 @@
from contextlib import ExitStack
from itertools import product
import numpy as np
from tiffwrite import IJTiffFile
from itertools import product
from contextlib import ExitStack
from tqdm.auto import tqdm
def test_mult(tmp_path):
shape = (3, 5, 12)
paths = [tmp_path / f'test{i}.tif' for i in range(8)]
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]
for c, z, t in tqdm(product(range(shape[0]), range(shape[1]), range(shape[2])), total=np.prod(shape)):
for tif in tifs:
tif.save(np.random.randint(0, 255, (1024, 1024)), c, z, t)
tif.save(np.random.randint(0, 255, (64, 64)), c, z, t)
assert all([path.exists() for path in paths])

View File

@@ -1,6 +1,7 @@
from itertools import product
import numpy as np
from tiffwrite import IJTiffFile
from itertools import product
def test_single(tmp_path):