Coverage for tests/images/metadata/test_pixel_calibration.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-31 11:24 +0000

1from qubalab.images.metadata.pixel_calibration import PixelLength, PixelCalibration 

2 

3 

4def test_default_pixel_length(): 

5 pixel_length = PixelLength() 

6 

7 is_default = pixel_length.is_default() 

8 

9 assert is_default 

10 

11 

12def test_default_values_of_pixel_length(): 

13 expected_pixel_length = PixelLength(1.0, 'pixels') 

14 

15 pixel_length = PixelLength() 

16 

17 assert expected_pixel_length == pixel_length 

18 

19 

20def test_length_and_unit_of_pixel_length_different(): 

21 pixel_length = PixelLength() 

22 pixel_length_microns = PixelLength.create_microns(0.25) 

23 

24 assert pixel_length != pixel_length_microns 

25 

26 

27def test_length(): 

28 length = 0.25 

29 

30 pixel_length = PixelLength.create_microns(length) 

31 

32 assert pixel_length.length == length 

33 

34 

35def test_unit(): 

36 unit = 'micrometer' 

37 

38 pixel_length = PixelLength.create_microns(0) 

39 

40 assert pixel_length.unit == unit 

41 

42 

43def test_default_pixel_calibration_not_calibrated(): 

44 pixel_calibration = PixelCalibration() 

45 

46 assert not pixel_calibration.is_calibrated() 

47 

48 

49def test_default_pixel_calibration_calibrated(): 

50 pixel_calibration = PixelCalibration(length_x=PixelLength.create_microns(0.25)) 

51 

52 assert pixel_calibration.is_calibrated()