Coverage for colorimetry/cmfs.py: 14%

1"""

2 Colour Matching Functions

3=========================

4

5 Define the colour matching functions classes for the datasets from

6 the :mod:`colour.colorimetry.datasets.cmfs` module:

7

8- :class:`colour.colorimetry.LMS_ConeFundamentals`: Define support for

9 *Stockman and Sharpe* *LMS* cone fundamentals colour matching functions.

10- :class:`colour.colorimetry.RGB_ColourMatchingFunctions`: Define support

11 for *CIE RGB* colour matching functions.

12- :class:`colour.colorimetry.XYZ_ColourMatchingFunctions`: Define support

13 for *CIE Standard Observers* *XYZ* colour matching functions.

14"""

15

16 from __future__ import annotations

17

18 import typing

19

20 from colour.colorimetry import (

21 MultiSpectralDistributions,

22 SpectralDistribution,

23 SpectralShape,

24)

25

26 if typing.TYPE_CHECKING:

27 from collections.abc import KeysView, ValuesView

28 from colour.continuous import MultiSignals, Signal

29 from colour.hints import (

30 Any,

31 ArrayLike,

32 Sequence,

33 )

34

35 from colour.utilities import is_pandas_installed

36

37 if typing.TYPE_CHECKING or is_pandas_installed():

38 from pandas import DataFrame, Series # pragma: no cover

39 else: # pragma: no cover

40 from unittest import mock

41

42 DataFrame = mock.MagicMock()

43 Series = mock.MagicMock()

44

45 __author__ = "Colour Developers"

46 __copyright__ = "Copyright 2013 Colour Developers"

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

48 __maintainer__ = "Colour Developers"

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

50 __status__ = "Production"

51

52 __all__ = [

53 "LMS_ConeFundamentals",

54 "RGB_ColourMatchingFunctions",

55 "XYZ_ColourMatchingFunctions",

56]

57

58

59 class LMS_ConeFundamentals(MultiSpectralDistributions):

60 """

61 Define a container for *Stockman and Sharpe* *LMS* cone fundamentals

62 colour matching functions.

63

64 Parameters

65 ----------

66 data

67 Data to be stored in the multi-spectral distributions.

68 domain

69 Values to initialise the multiple

70 :class:`colour.SpectralDistribution` class instances

71 :attr:`colour.continuous.Signal.wavelengths` attribute with. If

72 both ``data`` and ``domain`` arguments are defined, the latter will

73 be used to initialise the

74 :attr:`colour.continuous.Signal.wavelengths` property.

75 labels

76 Names to use for the :class:`colour.SpectralDistribution` class

77 instances.

78

79 Other Parameters

80 ----------------

81 extrapolator

82 Extrapolator class type to use as extrapolating function for the

83 :class:`colour.SpectralDistribution` class instances.

84 extrapolator_kwargs

85 Arguments to use when instantiating the extrapolating function of

86 the :class:`colour.SpectralDistribution` class instances.

87 interpolator

88 Interpolator class type to use as interpolating function for the

89 :class:`colour.SpectralDistribution` class instances.

90 interpolator_kwargs

91 Arguments to use when instantiating the interpolating function of

92 the :class:`colour.SpectralDistribution` class instances.

93 name

94 Multi-spectral distributions name.

95 display_labels

96 Multi-spectral distributions labels for figures, default to

97 :attr:`colour.colorimetry.LMS_ConeFundamentals.labels` property

98 value.

99 """

100

101 def __init__(

102 self,

103 data: (

104 ArrayLike

105 | DataFrame

106 | dict

107 | MultiSignals

108 | MultiSpectralDistributions

109 | Sequence

110 | Series

111 | Signal

112 | SpectralDistribution

113 | ValuesView

114 | None

115 ) = None,

116 domain: ArrayLike | SpectralShape | KeysView | None = None,

117 labels: Sequence | None = None, # noqa: ARG002

118 **kwargs: Any,

119 ) -> None:

120 super().__init__(

121 data,

122 domain,

123 labels=("l_bar", "m_bar", "s_bar"),

124 display_labels=("$\\bar{l}$", "$\\bar{m}$", "$\\bar{s}$"),

125 **kwargs,

126 )

127

128

129 class RGB_ColourMatchingFunctions(MultiSpectralDistributions):

130 """

131 Define a container for *CIE RGB* colour matching functions.

132

133 Parameters

134 ----------

135 data

136 Data to be stored in the multi-spectral distributions.

137 domain

138 Values to initialise the multiple

139 :class:`colour.SpectralDistribution` class instances

140 :attr:`colour.continuous.Signal.wavelengths` attribute with. If

141 both ``data`` and ``domain`` arguments are defined, the latter will

142 be used to initialise the

143 :attr:`colour.continuous.Signal.wavelengths` property.

144 labels

145 Names to use for the :class:`colour.SpectralDistribution` class

146 instances.

147

148 Other Parameters

149 ----------------

150 extrapolator

151 Extrapolator class type to use as extrapolating function for the

152 :class:`colour.SpectralDistribution` class instances.

153 extrapolator_kwargs

154 Arguments to use when instantiating the extrapolating function of

155 the :class:`colour.SpectralDistribution` class instances.

156 interpolator

157 Interpolator class type to use as interpolating function for the

158 :class:`colour.SpectralDistribution` class instances.

159 interpolator_kwargs

160 Arguments to use when instantiating the interpolating function of

161 the :class:`colour.SpectralDistribution` class instances.

162 name

163 Multi-spectral distributions name.

164 display_labels

165 Multi-spectral distributions labels for figures, default to

166 :attr:`colour.colorimetry.RGB_ColourMatchingFunctions.labels` property

167 value.

168 """

169

170 def __init__(

171 self,

172 data: (

173 ArrayLike

174 | DataFrame

175 | dict

176 | MultiSignals

177 | MultiSpectralDistributions

178 | Sequence

179 | Series

180 | Signal

181 | SpectralDistribution

182 | ValuesView

183 | None

184 ) = None,

185 domain: ArrayLike | SpectralShape | KeysView | None = None,

186 labels: Sequence | None = None, # noqa: ARG002

187 **kwargs: Any,

188 ) -> None:

189 super().__init__(

190 data,

191 domain,

192 labels=("r_bar", "g_bar", "b_bar"),

193 display_labels=("$\\bar{r}$", "$\\bar{g}$", "$\\bar{b}$"),

194 **kwargs,

195 )

196

197

198 class XYZ_ColourMatchingFunctions(MultiSpectralDistributions):

199 """

200 Define a container for *CIE* Standard Observers *XYZ* colour matching

201 functions.

202

203 Parameters

204 ----------

205 data

206 Data to be stored in the multi-spectral distributions.

207 domain

208 Values to initialise the multiple

209 :class:`colour.SpectralDistribution` class instances

210 :attr:`colour.continuous.Signal.wavelengths` attribute with. If

211 both ``data`` and ``domain`` arguments are defined, the latter will

212 be used to initialise the

213 :attr:`colour.continuous.Signal.wavelengths` property.

214 labels

215 Names to use for the :class:`colour.SpectralDistribution` class

216 instances.

217

218 Other Parameters

219 ----------------

220 extrapolator

221 Extrapolator class type to use as extrapolating function for the

222 :class:`colour.SpectralDistribution` class instances.

223 extrapolator_kwargs

224 Arguments to use when instantiating the extrapolating function of

225 the :class:`colour.SpectralDistribution` class instances.

226 interpolator

227 Interpolator class type to use as interpolating function for the

228 :class:`colour.SpectralDistribution` class instances.

229 interpolator_kwargs

230 Arguments to use when instantiating the interpolating function of

231 the :class:`colour.SpectralDistribution` class instances.

232 name

233 Multi-spectral distributions name.

234 display_labels

235 Multi-spectral distributions labels for figures, default to

236 :attr:`colour.colorimetry.XYZ_ColourMatchingFunctions.labels` property

237 value.

238 """

239

240 def __init__(

241 self,

242 data: (

243 ArrayLike

244 | DataFrame

245 | dict

246 | MultiSignals

247 | MultiSpectralDistributions

248 | Sequence

249 | Series

250 | Signal

251 | SpectralDistribution

252 | ValuesView

253 | None

254 ) = None,

255 domain: ArrayLike | SpectralShape | KeysView | None = None,

256 labels: Sequence | None = None, # noqa: ARG002

257 **kwargs: Any,

258 ) -> None:

259 super().__init__(

260 data,

261 domain,

262 labels=("x_bar", "y_bar", "z_bar"),

263 display_labels=("$\\bar{x}$", "$\\bar{y}$", "$\\bar{z}$"),

264 **kwargs,

265 )