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

1import pytest 

2from qubalab.images.metadata.image_shape import ImageShape 

3 

4 

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) 

13 

14 tuple = image_shape.as_tuple() 

15 

16 assert expected_tuple == tuple 

17 

18 

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) 

27 

28 tuple = image_shape.as_tuple('yx') 

29 

30 assert expected_tuple == tuple 

31 

32 

33def test_as_tuple_with_invalid_parameters(): 

34 with pytest.raises(AttributeError): 

35 image_shape = ImageShape(0, 0) 

36 

37 image_shape.as_tuple('a') 

38 

39 

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) 

47 

48 image_shape = ImageShape.from_tczyx(t, c, z, y, x) 

49 

50 assert expected_image_shape == image_shape 

51 

52 

53def test_from_invalid_tuple(): 

54 with pytest.raises(IndexError): 

55 ImageShape.from_tczyx()