Coverage for models/rgb/transfer_functions/tests/test_arri.py: 100%
119 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
1"""
2Define the unit tests for the
3:mod:`colour.models.rgb.transfer_functions.arri` module.
4"""
6import numpy as np
8from colour.constants import TOLERANCE_ABSOLUTE_TESTS
9from colour.models.rgb.transfer_functions import (
10 log_decoding_ARRILogC3,
11 log_decoding_ARRILogC4,
12 log_encoding_ARRILogC3,
13 log_encoding_ARRILogC4,
14)
15from colour.utilities import domain_range_scale, ignore_numpy_errors
17__author__ = "Colour Developers"
18__copyright__ = "Copyright 2013 Colour Developers"
19__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
20__maintainer__ = "Colour Developers"
21__email__ = "colour-developers@colour-science.org"
22__status__ = "Production"
24__all__ = [
25 "TestLogEncoding_ARRILogC3",
26 "TestLogDecoding_ARRILogC3",
27 "TestLogEncoding_ARRILogC4",
28 "TestLogDecoding_ARRILogC4",
29]
32class TestLogEncoding_ARRILogC3:
33 """
34 Define :func:`colour.models.rgb.transfer_functions.arri.\
35log_encoding_ARRILogC3` definition unit tests methods.
36 """
38 def test_log_encoding_ARRILogC3(self) -> None:
39 """
40 Test :func:`colour.models.rgb.transfer_functions.arri.\
41log_encoding_ARRILogC3` definition.
42 """
44 np.testing.assert_allclose(
45 log_encoding_ARRILogC3(0.0),
46 0.092809000000000,
47 atol=TOLERANCE_ABSOLUTE_TESTS,
48 )
50 np.testing.assert_allclose(
51 log_encoding_ARRILogC3(0.18),
52 0.391006832034084,
53 atol=TOLERANCE_ABSOLUTE_TESTS,
54 )
56 np.testing.assert_allclose(
57 log_encoding_ARRILogC3(1.0),
58 0.570631558120417,
59 atol=TOLERANCE_ABSOLUTE_TESTS,
60 )
62 def test_n_dimensional_log_encoding_ARRILogC3(self) -> None:
63 """
64 Test :func:`colour.models.rgb.transfer_functions.arri.\
65log_encoding_ARRILogC3` definition n-dimensional arrays support.
66 """
68 x = 0.18
69 t = log_encoding_ARRILogC3(x)
71 x = np.tile(x, 6)
72 t = np.tile(t, 6)
73 np.testing.assert_allclose(
74 log_encoding_ARRILogC3(x), t, atol=TOLERANCE_ABSOLUTE_TESTS
75 )
77 x = np.reshape(x, (2, 3))
78 t = np.reshape(t, (2, 3))
79 np.testing.assert_allclose(
80 log_encoding_ARRILogC3(x), t, atol=TOLERANCE_ABSOLUTE_TESTS
81 )
83 x = np.reshape(x, (2, 3, 1))
84 t = np.reshape(t, (2, 3, 1))
85 np.testing.assert_allclose(
86 log_encoding_ARRILogC3(x), t, atol=TOLERANCE_ABSOLUTE_TESTS
87 )
89 def test_domain_range_scale_log_encoding_ARRILogC3(self) -> None:
90 """
91 Test :func:`colour.models.rgb.transfer_functions.arri.\
92log_encoding_ARRILogC3` definition domain and range scale support.
93 """
95 x = 0.18
96 t = log_encoding_ARRILogC3(x)
98 d_r = (("reference", 1), ("1", 1), ("100", 100))
99 for scale, factor in d_r:
100 with domain_range_scale(scale):
101 np.testing.assert_allclose(
102 log_encoding_ARRILogC3(x * factor),
103 t * factor,
104 atol=TOLERANCE_ABSOLUTE_TESTS,
105 )
107 @ignore_numpy_errors
108 def test_nan_log_encoding_ARRILogC3(self) -> None:
109 """
110 Test :func:`colour.models.rgb.transfer_functions.arri.\
111log_encoding_ARRILogC3` definition nan support.
112 """
114 log_encoding_ARRILogC3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
117class TestLogDecoding_ARRILogC3:
118 """
119 Define :func:`colour.models.rgb.transfer_functions.arri.\
120log_decoding_ARRILogC3` definition unit tests methods.
121 """
123 def test_log_decoding_ARRILogC3(self) -> None:
124 """
125 Test :func:`colour.models.rgb.transfer_functions.arri.\
126log_decoding_ARRILogC3` definition.
127 """
129 np.testing.assert_allclose(
130 log_decoding_ARRILogC3(0.092809),
131 0.0,
132 atol=TOLERANCE_ABSOLUTE_TESTS,
133 )
135 np.testing.assert_allclose(
136 log_decoding_ARRILogC3(0.391006832034084),
137 0.18,
138 atol=TOLERANCE_ABSOLUTE_TESTS,
139 )
141 np.testing.assert_allclose(
142 log_decoding_ARRILogC3(0.570631558120417),
143 1.0,
144 atol=TOLERANCE_ABSOLUTE_TESTS,
145 )
147 def test_n_dimensional_log_decoding_ARRILogC3(self) -> None:
148 """
149 Test :func:`colour.models.rgb.transfer_functions.arri.\
150log_decoding_ARRILogC3` definition n-dimensional arrays support.
151 """
153 t = 0.391006832034084
154 x = log_decoding_ARRILogC3(t)
156 t = np.tile(t, 6)
157 x = np.tile(x, 6)
158 np.testing.assert_allclose(
159 log_decoding_ARRILogC3(t), x, atol=TOLERANCE_ABSOLUTE_TESTS
160 )
162 t = np.reshape(t, (2, 3))
163 x = np.reshape(x, (2, 3))
164 np.testing.assert_allclose(
165 log_decoding_ARRILogC3(t), x, atol=TOLERANCE_ABSOLUTE_TESTS
166 )
168 t = np.reshape(t, (2, 3, 1))
169 x = np.reshape(x, (2, 3, 1))
170 np.testing.assert_allclose(
171 log_decoding_ARRILogC3(t), x, atol=TOLERANCE_ABSOLUTE_TESTS
172 )
174 def test_domain_range_scale_log_decoding_ARRILogC3(self) -> None:
175 """
176 Test :func:`colour.models.rgb.transfer_functions.arri.\
177log_decoding_ARRILogC3` definition domain and range scale support.
178 """
180 t = 0.391006832034084
181 x = log_decoding_ARRILogC3(t)
183 d_r = (("reference", 1), ("1", 1), ("100", 100))
184 for scale, factor in d_r:
185 with domain_range_scale(scale):
186 np.testing.assert_allclose(
187 log_decoding_ARRILogC3(t * factor),
188 x * factor,
189 atol=TOLERANCE_ABSOLUTE_TESTS,
190 )
192 @ignore_numpy_errors
193 def test_nan_log_decoding_ARRILogC3(self) -> None:
194 """
195 Test :func:`colour.models.rgb.transfer_functions.arri.\
196log_decoding_ARRILogC3` definition nan support.
197 """
199 log_decoding_ARRILogC3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
202class TestLogEncoding_ARRILogC4:
203 """
204 Define :func:`colour.models.rgb.transfer_functions.arri.\
205log_encoding_ARRILogC4` definition unit tests methods.
206 """
208 def test_log_encoding_ARRILogC4(self) -> None:
209 """
210 Test :func:`colour.models.rgb.transfer_functions.arri.\
211log_encoding_ARRILogC4` definition.
212 """
214 np.testing.assert_allclose(
215 log_encoding_ARRILogC4(0.0),
216 0.092864125122190,
217 atol=TOLERANCE_ABSOLUTE_TESTS,
218 )
220 np.testing.assert_allclose(
221 log_encoding_ARRILogC4(0.18),
222 0.278395836548265,
223 atol=TOLERANCE_ABSOLUTE_TESTS,
224 )
226 np.testing.assert_allclose(
227 log_encoding_ARRILogC4(1.0),
228 0.427519364835306,
229 atol=TOLERANCE_ABSOLUTE_TESTS,
230 )
232 def test_n_dimensional_log_encoding_ARRILogC4(self) -> None:
233 """
234 Test :func:`colour.models.rgb.transfer_functions.arri.\
235log_encoding_ARRILogC4` definition n-dimensional arrays support.
236 """
238 x = 0.18
239 t = log_encoding_ARRILogC4(x)
241 x = np.tile(x, 6)
242 t = np.tile(t, 6)
243 np.testing.assert_allclose(
244 log_encoding_ARRILogC4(x), t, atol=TOLERANCE_ABSOLUTE_TESTS
245 )
247 x = np.reshape(x, (2, 3))
248 t = np.reshape(t, (2, 3))
249 np.testing.assert_allclose(
250 log_encoding_ARRILogC4(x), t, atol=TOLERANCE_ABSOLUTE_TESTS
251 )
253 x = np.reshape(x, (2, 3, 1))
254 t = np.reshape(t, (2, 3, 1))
255 np.testing.assert_allclose(
256 log_encoding_ARRILogC4(x), t, atol=TOLERANCE_ABSOLUTE_TESTS
257 )
259 def test_domain_range_scale_log_encoding_ARRILogC4(self) -> None:
260 """
261 Test :func:`colour.models.rgb.transfer_functions.arri.\
262log_encoding_ARRILogC4` definition domain and range scale support.
263 """
265 x = 0.18
266 t = log_encoding_ARRILogC4(x)
268 d_r = (("reference", 1), ("1", 1), ("100", 100))
269 for scale, factor in d_r:
270 with domain_range_scale(scale):
271 np.testing.assert_allclose(
272 log_encoding_ARRILogC4(x * factor),
273 t * factor,
274 atol=TOLERANCE_ABSOLUTE_TESTS,
275 )
277 @ignore_numpy_errors
278 def test_nan_log_encoding_ARRILogC4(self) -> None:
279 """
280 Test :func:`colour.models.rgb.transfer_functions.arri.\
281log_encoding_ARRILogC4` definition nan support.
282 """
284 log_encoding_ARRILogC4(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
287class TestLogDecoding_ARRILogC4:
288 """
289 Define :func:`colour.models.rgb.transfer_functions.arri.\
290log_decoding_ARRILogC4` definition unit tests methods.
291 """
293 def test_log_decoding_ARRILogC4(self) -> None:
294 """
295 Test :func:`colour.models.rgb.transfer_functions.arri.\
296log_decoding_ARRILogC4` definition.
297 """
299 np.testing.assert_allclose(
300 log_decoding_ARRILogC4(0.092864125122190),
301 0.0,
302 atol=TOLERANCE_ABSOLUTE_TESTS,
303 )
305 np.testing.assert_allclose(
306 log_decoding_ARRILogC4(0.278395836548265),
307 0.18,
308 atol=TOLERANCE_ABSOLUTE_TESTS,
309 )
311 np.testing.assert_allclose(
312 log_decoding_ARRILogC4(0.427519364835306),
313 1.0,
314 atol=TOLERANCE_ABSOLUTE_TESTS,
315 )
317 def test_n_dimensional_log_decoding_ARRILogC4(self) -> None:
318 """
319 Test :func:`colour.models.rgb.transfer_functions.arri.\
320log_decoding_ARRILogC4` definition n-dimensional arrays support.
321 """
323 t = 0.278395836548265
324 x = log_decoding_ARRILogC4(t)
326 t = np.tile(t, 6)
327 x = np.tile(x, 6)
328 np.testing.assert_allclose(
329 log_decoding_ARRILogC4(t), x, atol=TOLERANCE_ABSOLUTE_TESTS
330 )
332 t = np.reshape(t, (2, 3))
333 x = np.reshape(x, (2, 3))
334 np.testing.assert_allclose(
335 log_decoding_ARRILogC4(t), x, atol=TOLERANCE_ABSOLUTE_TESTS
336 )
338 t = np.reshape(t, (2, 3, 1))
339 x = np.reshape(x, (2, 3, 1))
340 np.testing.assert_allclose(
341 log_decoding_ARRILogC4(t), x, atol=TOLERANCE_ABSOLUTE_TESTS
342 )
344 def test_domain_range_scale_log_decoding_ARRILogC4(self) -> None:
345 """
346 Test :func:`colour.models.rgb.transfer_functions.arri.\
347log_decoding_ARRILogC4` definition domain and range scale support.
348 """
350 t = 0.278395836548265
351 x = log_decoding_ARRILogC4(t)
353 d_r = (("reference", 1), ("1", 1), ("100", 100))
354 for scale, factor in d_r:
355 with domain_range_scale(scale):
356 np.testing.assert_allclose(
357 log_decoding_ARRILogC4(t * factor),
358 x * factor,
359 atol=TOLERANCE_ABSOLUTE_TESTS,
360 )
362 @ignore_numpy_errors
363 def test_nan_log_decoding_ARRILogC4(self) -> None:
364 """
365 Test :func:`colour.models.rgb.transfer_functions.arri.\
366log_decoding_ARRILogC4` definition nan support.
367 """
369 log_decoding_ARRILogC4(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))