Coverage for tests/images/metadata/test_image_shape.py: 100%
38 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-31 11:24 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-31 11:24 +0000
1import pytest
2from qubalab.images.metadata.image_shape import ImageShape
5def test_as_tuple():
6 x = 1
7 y = 2
8 z = 3
9 t = 4
10 c = 5
11 expected_tuple = (t, c, z, y, x)
12 image_shape = ImageShape(x=x, y=y, t=t, z=z, c=c)
14 tuple = image_shape.as_tuple()
16 assert expected_tuple == tuple
19def test_as_tuple_with_parameters():
20 x = 1
21 y = 2
22 z = 3
23 t = 4
24 c = 5
25 expected_tuple = (y, x)
26 image_shape = ImageShape(x=x, y=y, t=t, z=z, c=c)
28 tuple = image_shape.as_tuple('yx')
30 assert expected_tuple == tuple
33def test_as_tuple_with_invalid_parameters():
34 with pytest.raises(AttributeError):
35 image_shape = ImageShape(0, 0)
37 image_shape.as_tuple('a')
40def test_from_tuple():
41 x = 1
42 y = 2
43 z = 3
44 t = 4
45 c = 5
46 expected_image_shape = ImageShape(x=x, y=y, t=t, z=z, c=c)
48 image_shape = ImageShape.from_tczyx(t, c, z, y, x)
50 assert expected_image_shape == image_shape
53def test_from_invalid_tuple():
54 with pytest.raises(IndexError):
55 ImageShape.from_tczyx()