Coverage for colour/quality/__init__.py: 100%

23 statements  

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

1from __future__ import annotations 

2 

3import typing 

4 

5if typing.TYPE_CHECKING: 

6 from colour.colorimetry import SpectralDistribution 

7 from colour.hints import Literal 

8 

9from colour.utilities import CanonicalMapping, validate_method 

10 

11from . import datasets 

12from .cfi2017 import ( 

13 ColourRendering_Specification_CIE2017, 

14 colour_fidelity_index_CIE2017, 

15) 

16from .cqs import ( 

17 COLOUR_QUALITY_SCALE_METHODS, 

18 ColourRendering_Specification_CQS, 

19 colour_quality_scale, 

20) 

21from .cri import ( 

22 COLOUR_RENDERING_INDEX_METHODS, 

23 ColourRendering_Specification_CRI, 

24 colour_rendering_index, 

25) 

26from .datasets import * # noqa: F403 

27from .ssi import spectral_similarity_index 

28from .tm3018 import ( 

29 ColourQuality_Specification_ANSIIESTM3018, 

30 colour_fidelity_index_ANSIIESTM3018, 

31) 

32 

33__all__ = datasets.__all__ 

34__all__ += [ 

35 "ColourRendering_Specification_CIE2017", 

36 "colour_fidelity_index_CIE2017", 

37] 

38__all__ += [ 

39 "COLOUR_QUALITY_SCALE_METHODS", 

40 "ColourRendering_Specification_CQS", 

41 "colour_quality_scale", 

42] 

43__all__ += [ 

44 "COLOUR_RENDERING_INDEX_METHODS", 

45 "ColourRendering_Specification_CRI", 

46 "colour_rendering_index", 

47] 

48__all__ += [ 

49 "spectral_similarity_index", 

50] 

51__all__ += [ 

52 "ColourQuality_Specification_ANSIIESTM3018", 

53 "colour_fidelity_index_ANSIIESTM3018", 

54] 

55 

56COLOUR_FIDELITY_INDEX_METHODS = CanonicalMapping( 

57 { 

58 "CIE 2017": colour_fidelity_index_CIE2017, 

59 "ANSI/IES TM-30-18": colour_fidelity_index_ANSIIESTM3018, 

60 } 

61) 

62COLOUR_FIDELITY_INDEX_METHODS.__doc__ = """ 

63Supported *Colour Fidelity Index* (CFI) computation methods. 

64 

65References 

66---------- 

67:cite:`CIETC1-902017`, :cite:`ANSI2018` 

68""" 

69 

70 

71def colour_fidelity_index( 

72 sd_test: SpectralDistribution, 

73 additional_data: bool = False, 

74 method: Literal["CIE 2017", "ANSI/IES TM-30-18"] | str = "CIE 2017", 

75) -> ( 

76 float 

77 | ColourRendering_Specification_CIE2017 

78 | ColourQuality_Specification_ANSIIESTM3018 

79): 

80 """ 

81 Compute the *Colour Fidelity Index* (CFI) :math:`R_f` of the specified 

82 spectral distribution using the specified method. 

83 

84 Parameters 

85 ---------- 

86 sd_test 

87 Test spectral distribution. 

88 additional_data 

89 Whether to output additional data. 

90 method 

91 Computation method. 

92 

93 Returns 

94 ------- 

95 :class:`float` or \ 

96:class:`colour.quality.ColourRendering_Specification_CIE2017` or \ 

97:class:`colour.quality.ColourQuality_Specification_ANSIIESTM3018` 

98 *Colour Fidelity Index* (CFI) :math:`R_f`. 

99 

100 References 

101 ---------- 

102 :cite:`CIETC1-902017`, :cite:`ANSI2018` 

103 

104 Examples 

105 -------- 

106 >>> from colour.colorimetry import SDS_ILLUMINANTS 

107 >>> sd = SDS_ILLUMINANTS["FL2"] 

108 >>> colour_fidelity_index(sd) # doctest: +ELLIPSIS 

109 70.1208244... 

110 """ 

111 

112 method = validate_method(method, tuple(COLOUR_FIDELITY_INDEX_METHODS)) 

113 

114 function = COLOUR_FIDELITY_INDEX_METHODS[method] 

115 

116 return function(sd_test, additional_data) 

117 

118 

119__all__ += [ 

120 "COLOUR_FIDELITY_INDEX_METHODS", 

121 "colour_fidelity_index", 

122]