- remove all readers but bioformats
- open folder with sequence
This commit is contained in:
@@ -1,27 +1,21 @@
|
||||
import pickle
|
||||
from multiprocessing import active_children
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from ndbioimage import Imread, ReaderNotFoundError
|
||||
from ndbioimage import Imread
|
||||
|
||||
|
||||
@pytest.mark.parametrize('file', (Path(__file__).parent / 'files').iterdir())
|
||||
@pytest.mark.parametrize('file',
|
||||
[file for file in (Path(__file__).parent / 'files').iterdir() if not file.suffix == '.pzl'])
|
||||
def test_open(file):
|
||||
try:
|
||||
with Imread(file) as im:
|
||||
mean = im[dict(c=0, z=0, t=0)].mean()
|
||||
b = pickle.dumps(im)
|
||||
jm = pickle.loads(b)
|
||||
assert jm[dict(c=0, z=0, t=0)].mean() == mean
|
||||
v = im.view()
|
||||
assert v[dict(c=0, z=0, t=0)].mean() == mean
|
||||
b = pickle.dumps(v)
|
||||
w = pickle.loads(b)
|
||||
assert w[dict(c=0, z=0, t=0)].mean() == mean
|
||||
except ReaderNotFoundError:
|
||||
assert len(Imread.__subclasses__()), 'No subclasses for Imread found.'
|
||||
|
||||
for child in active_children():
|
||||
child.kill()
|
||||
with Imread(file) as im:
|
||||
mean = im[dict(c=0, z=0, t=0)].mean()
|
||||
b = pickle.dumps(im)
|
||||
jm = pickle.loads(b)
|
||||
assert jm[dict(c=0, z=0, t=0)].mean() == mean
|
||||
v = im.view()
|
||||
assert v[dict(c=0, z=0, t=0)].mean() == mean
|
||||
b = pickle.dumps(v)
|
||||
w = pickle.loads(b)
|
||||
assert w[dict(c=0, z=0, t=0)].mean() == mean
|
||||
|
||||
@@ -1,20 +1,32 @@
|
||||
import tempfile
|
||||
from itertools import combinations_with_replacement
|
||||
from numbers import Number
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
from tiffwrite import tiffwrite
|
||||
|
||||
from ndbioimage import Imread
|
||||
|
||||
r = np.random.randint(0, 255, (64, 64, 2, 3, 4))
|
||||
im = Imread(r)
|
||||
a = np.array(im)
|
||||
|
||||
@pytest.fixture
|
||||
def array():
|
||||
return np.random.randint(0, 255, (64, 64, 2, 3, 4), 'uint8')
|
||||
|
||||
@pytest.fixture()
|
||||
def image(array):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
file = Path(folder) / "test.tif"
|
||||
tiffwrite(file, array, 'yxczt')
|
||||
with Imread(file, axes='yxczt') as im:
|
||||
yield im
|
||||
|
||||
|
||||
@pytest.mark.parametrize('s', combinations_with_replacement(
|
||||
(0, -1, 1, slice(None), slice(0, 1), slice(-1, 0), slice(1, 1)), 5))
|
||||
def test_slicing(s):
|
||||
s_im, s_a = im[s], a[s]
|
||||
def test_slicing(s, image, array):
|
||||
s_im, s_a = image[s], array[s]
|
||||
if isinstance(s_a, Number):
|
||||
assert isinstance(s_im, Number)
|
||||
assert s_im == s_a
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
import tempfile
|
||||
from itertools import product
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
from tiffwrite import tiffwrite
|
||||
|
||||
from ndbioimage import Imread
|
||||
|
||||
r = np.random.randint(0, 255, (64, 64, 2, 3, 4))
|
||||
im = Imread(r)
|
||||
a = np.array(im)
|
||||
|
||||
@pytest.fixture
|
||||
def array():
|
||||
return np.random.randint(0, 255, (64, 64, 2, 3, 4), 'uint16')
|
||||
|
||||
@pytest.fixture()
|
||||
def image(array):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
file = Path(folder) / "test.tif"
|
||||
tiffwrite(file, array, 'yxczt')
|
||||
with Imread(file, axes='yxczt') as im:
|
||||
yield im
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fun_and_axis', product(
|
||||
(np.sum, np.nansum, np.min, np.nanmin, np.max, np.nanmax, np.argmin, np.argmax,
|
||||
np.mean, np.nanmean, np.var, np.nanvar, np.std, np.nanstd), (None, 0, 1, 2, 3, 4)))
|
||||
def test_ufuncs(fun_and_axis):
|
||||
def test_ufuncs(fun_and_axis, image, array):
|
||||
fun, axis = fun_and_axis
|
||||
assert np.all(np.isclose(fun(im, axis), fun(a, axis))), \
|
||||
assert np.all(np.isclose(fun(image, axis), fun(array, axis))), \
|
||||
f'function {fun.__name__} over axis {axis} does not give the correct result'
|
||||
|
||||
Reference in New Issue
Block a user