- Make bioformats optional because jpype can cause problems

- Ruff format
This commit is contained in:
Wim Pomp
2025-08-06 11:03:03 +02:00
parent 3346ed3a48
commit 1fe3b3c824
17 changed files with 1223 additions and 794 deletions

View File

@@ -7,7 +7,7 @@ import pytest
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:
@@ -21,7 +21,7 @@ def test_open(file):
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()

View File

@@ -11,8 +11,9 @@ im = Imread(r)
a = np.array(im)
@pytest.mark.parametrize('s', combinations_with_replacement(
(0, -1, 1, slice(None), slice(0, 1), slice(-1, 0), slice(1, 1)), 5))
@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]
if isinstance(s_a, Number):

View File

@@ -10,10 +10,30 @@ 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)))
@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'
assert np.all(np.isclose(fun(im, axis), fun(a, axis))), (
f"function {fun.__name__} over axis {axis} does not give the correct result"
)