- base & view model for imread
- transforms bugfix - implement (nan)var and (nan)std - add tests
This commit is contained in:
BIN
tests/files/YTL1849A111_2023_05_04__14_46_19_cellnr_1_track.tif
Normal file
BIN
tests/files/YTL1849A111_2023_05_04__14_46_19_cellnr_1_track.tif
Normal file
Binary file not shown.
@@ -1,12 +1,25 @@
|
||||
import pickle
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from multiprocessing import active_children
|
||||
from ndbioimage import Imread, ReaderNotFoundError
|
||||
|
||||
|
||||
@pytest.mark.parametrize("file", (Path(__file__).parent / 'files').iterdir())
|
||||
@pytest.mark.parametrize('file', (Path(__file__).parent / 'files').iterdir())
|
||||
def test_open(file):
|
||||
try:
|
||||
with Imread(file) as im:
|
||||
print(im[dict(c=0, z=0, t=0)].mean())
|
||||
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."
|
||||
assert len(Imread.__subclasses__()), 'No subclasses for Imread found.'
|
||||
|
||||
for child in active_children():
|
||||
child.kill()
|
||||
|
||||
18
tests/test_ufuncs.py
Normal file
18
tests/test_ufuncs.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
from ndbioimage import Imread
|
||||
from itertools import product
|
||||
|
||||
|
||||
r = np.random.randint(0, 255, (64, 64, 2, 3, 4))
|
||||
im = Imread(r)
|
||||
a = np.array(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):
|
||||
fun, axis = fun_and_axis
|
||||
assert np.all(np.isclose(fun(im, axis), fun(a, axis))), \
|
||||
f'function {fun.__name__} over axis {axis} does not give the correct result'
|
||||
Reference in New Issue
Block a user