Coverage for colour/quality/tests/test__init__.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-16 23:01 +1300

1"""Define the unit tests for the :mod:`colour.quality` module.""" 

2 

3from __future__ import annotations 

4 

5from colour.colorimetry import SpectralDistribution 

6from colour.quality import colour_fidelity_index, colour_fidelity_index_CIE2017 

7 

8__author__ = "Colour Developers" 

9__copyright__ = "Copyright 2013 Colour Developers" 

10__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" 

11__maintainer__ = "Colour Developers" 

12__email__ = "colour-developers@colour-science.org" 

13__status__ = "Production" 

14 

15__all__ = [ 

16 "TestColourFidelityIndex", 

17] 

18 

19SD_SAMPLE_5NM = SpectralDistribution( 

20 { 

21 380: 0.000000, 

22 385: 0.000000, 

23 390: 0.000000, 

24 395: 0.000000, 

25 400: 0.000642, 

26 405: 0.001794, 

27 410: 0.003869, 

28 415: 0.007260, 

29 420: 0.013684, 

30 425: 0.022404, 

31 430: 0.033320, 

32 435: 0.046180, 

33 440: 0.061634, 

34 445: 0.080328, 

35 450: 0.102237, 

36 455: 0.128970, 

37 460: 0.160470, 

38 465: 0.197828, 

39 470: 0.239503, 

40 475: 0.283953, 

41 480: 0.329005, 

42 485: 0.375990, 

43 490: 0.427058, 

44 495: 0.481182, 

45 500: 0.538935, 

46 505: 0.601326, 

47 510: 0.667810, 

48 515: 0.737560, 

49 520: 0.805584, 

50 525: 0.869760, 

51 530: 0.926894, 

52 535: 0.973047, 

53 540: 1.000000, 

54 545: 1.000000, 

55 550: 0.974168, 

56 555: 0.922383, 

57 560: 0.844381, 

58 565: 0.745335, 

59 570: 0.631498, 

60 575: 0.513094, 

61 580: 0.398057, 

62 585: 0.294135, 

63 590: 0.206677, 

64 595: 0.137232, 

65 600: 0.085690, 

66 605: 0.051055, 

67 610: 0.029677, 

68 615: 0.016702, 

69 620: 0.009289, 

70 625: 0.005141, 

71 630: 0.002809, 

72 635: 0.001529, 

73 640: 0.000831, 

74 645: 0.000452, 

75 650: 0.000246, 

76 655: 0.000134, 

77 660: 0.000073, 

78 665: 0.000040, 

79 670: 0.000022, 

80 675: 0.000012, 

81 680: 0.000006, 

82 685: 0.000004, 

83 690: 0.000002, 

84 695: 0.000001, 

85 700: 0.000001, 

86 705: 0.000000, 

87 710: 0.000000, 

88 715: 0.000000, 

89 720: 0.000000, 

90 725: 0.000000, 

91 730: 0.000000, 

92 735: 0.000000, 

93 740: 0.000000, 

94 745: 0.000000, 

95 750: 0.000000, 

96 755: 0.000000, 

97 760: 0.000000, 

98 765: 0.000000, 

99 770: 0.000000, 

100 775: 0.000000, 

101 780: 0.000000, 

102 } 

103) 

104 

105 

106class TestColourFidelityIndex: 

107 """ 

108 Define :func:`colour.quality.colour_fidelity_index` definition 

109 unit tests methods. 

110 """ 

111 

112 def test_colour_fidelity_index(self) -> None: 

113 """Test :func:`colour.quality.colour_fidelity_index` definition.""" 

114 

115 sd = SD_SAMPLE_5NM 

116 

117 # Test default method (CIE 2017) 

118 assert colour_fidelity_index(sd) == colour_fidelity_index_CIE2017(sd) 

119 

120 # Test explicit CIE 2017 method 

121 assert colour_fidelity_index( 

122 sd, method="CIE 2017" 

123 ) == colour_fidelity_index_CIE2017(sd)