Coverage for models/rgb/transfer_functions/tests/test_fujifilm_f_log.py: 100%
131 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 :mod:`colour.models.rgb.transfer_functions.\
3fujifilm_f_log` module.
4"""
6import numpy as np
8from colour.constants import TOLERANCE_ABSOLUTE_TESTS
9from colour.models.rgb.transfer_functions import (
10 log_decoding_FLog,
11 log_decoding_FLog2,
12 log_encoding_FLog,
13 log_encoding_FLog2,
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_FLog",
26 "TestLogDecoding_FLog",
27 "TestLogEncoding_FLog2",
28 "TestLogDecoding_FLog2",
29]
32class TestLogEncoding_FLog:
33 """
34 Define :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
35log_encoding_FLog` definition unit tests methods.
36 """
38 def test_log_encoding_FLog(self) -> None:
39 """
40 Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
41log_encoding_FLog` definition.
42 """
44 np.testing.assert_allclose(
45 log_encoding_FLog(0.0),
46 0.092864000000000,
47 atol=TOLERANCE_ABSOLUTE_TESTS,
48 )
50 np.testing.assert_allclose(
51 log_encoding_FLog(0.18),
52 0.459318458661621,
53 atol=TOLERANCE_ABSOLUTE_TESTS,
54 )
56 np.testing.assert_allclose(
57 log_encoding_FLog(0.18, 12),
58 0.459318458661621,
59 atol=TOLERANCE_ABSOLUTE_TESTS,
60 )
62 np.testing.assert_allclose(
63 log_encoding_FLog(0.18, 10, False),
64 0.463336510514656,
65 atol=TOLERANCE_ABSOLUTE_TESTS,
66 )
68 np.testing.assert_allclose(
69 log_encoding_FLog(0.18, 10, False, False),
70 0.446590337236003,
71 atol=TOLERANCE_ABSOLUTE_TESTS,
72 )
74 np.testing.assert_allclose(
75 log_encoding_FLog(1.0),
76 0.704996409216428,
77 atol=TOLERANCE_ABSOLUTE_TESTS,
78 )
80 def test_n_dimensional_log_encoding_FLog(self) -> None:
81 """
82 Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
83log_encoding_FLog` definition n-dimensional arrays support.
84 """
86 L_in = 0.18
87 V_out = log_encoding_FLog(L_in)
89 L_in = np.tile(L_in, 6)
90 V_out = np.tile(V_out, 6)
91 np.testing.assert_allclose(
92 log_encoding_FLog(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS
93 )
95 L_in = np.reshape(L_in, (2, 3))
96 V_out = np.reshape(V_out, (2, 3))
97 np.testing.assert_allclose(
98 log_encoding_FLog(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS
99 )
101 L_in = np.reshape(L_in, (2, 3, 1))
102 V_out = np.reshape(V_out, (2, 3, 1))
103 np.testing.assert_allclose(
104 log_encoding_FLog(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS
105 )
107 def test_domain_range_scale_log_encoding_FLog(self) -> None:
108 """
109 Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
110log_encoding_FLog` definition domain and range scale support.
111 """
113 L_in = 0.18
114 V_out = log_encoding_FLog(L_in)
116 d_r = (("reference", 1), ("1", 1), ("100", 100))
117 for scale, factor in d_r:
118 with domain_range_scale(scale):
119 np.testing.assert_allclose(
120 log_encoding_FLog(L_in * factor),
121 V_out * factor,
122 atol=TOLERANCE_ABSOLUTE_TESTS,
123 )
125 @ignore_numpy_errors
126 def test_nan_log_encoding_FLog(self) -> None:
127 """
128 Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
129log_encoding_FLog` definition nan support.
130 """
132 log_encoding_FLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
135class TestLogDecoding_FLog:
136 """
137 Define :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
138log_decoding_FLog` definition unit tests methods.
139 """
141 def test_log_decoding_FLog(self) -> None:
142 """
143 Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
144log_decoding_FLog` definition.
145 """
147 np.testing.assert_allclose(
148 log_decoding_FLog(0.092864000000000),
149 0.0,
150 atol=TOLERANCE_ABSOLUTE_TESTS,
151 )
153 np.testing.assert_allclose(
154 log_decoding_FLog(0.459318458661621),
155 0.18,
156 atol=TOLERANCE_ABSOLUTE_TESTS,
157 )
159 np.testing.assert_allclose(
160 log_decoding_FLog(0.459318458661621, 12),
161 0.18,
162 atol=TOLERANCE_ABSOLUTE_TESTS,
163 )
165 np.testing.assert_allclose(
166 log_decoding_FLog(0.463336510514656, 10, False),
167 0.18,
168 atol=TOLERANCE_ABSOLUTE_TESTS,
169 )
171 np.testing.assert_allclose(
172 log_decoding_FLog(0.446590337236003, 10, False, False),
173 0.18,
174 atol=TOLERANCE_ABSOLUTE_TESTS,
175 )
177 np.testing.assert_allclose(
178 log_decoding_FLog(0.704996409216428),
179 1.0,
180 atol=TOLERANCE_ABSOLUTE_TESTS,
181 )
183 def test_n_dimensional_log_decoding_FLog(self) -> None:
184 """
185 Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
186log_decoding_FLog` definition n-dimensional arrays support.
187 """
189 V_out = 0.459318458661621
190 L_in = log_decoding_FLog(V_out)
192 V_out = np.tile(V_out, 6)
193 L_in = np.tile(L_in, 6)
194 np.testing.assert_allclose(
195 log_decoding_FLog(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS
196 )
198 V_out = np.reshape(V_out, (2, 3))
199 L_in = np.reshape(L_in, (2, 3))
200 np.testing.assert_allclose(
201 log_decoding_FLog(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS
202 )
204 V_out = np.reshape(V_out, (2, 3, 1))
205 L_in = np.reshape(L_in, (2, 3, 1))
206 np.testing.assert_allclose(
207 log_decoding_FLog(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS
208 )
210 def test_domain_range_scale_log_decoding_FLog(self) -> None:
211 """
212 Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
213log_decoding_FLog` definition domain and range scale support.
214 """
216 V_out = 0.459318458661621
217 L_in = log_decoding_FLog(V_out)
219 d_r = (("reference", 1), ("1", 1), ("100", 100))
220 for scale, factor in d_r:
221 with domain_range_scale(scale):
222 np.testing.assert_allclose(
223 log_decoding_FLog(V_out * factor),
224 L_in * factor,
225 atol=TOLERANCE_ABSOLUTE_TESTS,
226 )
228 @ignore_numpy_errors
229 def test_nan_log_decoding_FLog(self) -> None:
230 """
231 Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\
232log_decoding_FLog` definition nan support.
233 """
235 log_decoding_FLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
238class TestLogEncoding_FLog2:
239 """
240 Define :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
241log_encoding_FLog2` definition unit tests methods.
242 """
244 def test_log_encoding_FLog2(self) -> None:
245 """
246 Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
247log_encoding_FLog2` definition.
248 """
250 np.testing.assert_allclose(
251 log_encoding_FLog2(0.0),
252 0.092864000000000,
253 atol=TOLERANCE_ABSOLUTE_TESTS,
254 )
256 np.testing.assert_allclose(
257 log_encoding_FLog2(0.18),
258 0.39100724189123,
259 atol=TOLERANCE_ABSOLUTE_TESTS,
260 )
262 np.testing.assert_allclose(
263 log_encoding_FLog2(0.18, 12),
264 0.39100724189123,
265 atol=TOLERANCE_ABSOLUTE_TESTS,
266 )
268 np.testing.assert_allclose(
269 log_encoding_FLog2(0.18, 10, False),
270 0.383562110108137,
271 atol=TOLERANCE_ABSOLUTE_TESTS,
272 )
274 np.testing.assert_allclose(
275 log_encoding_FLog2(0.18, 10, False, False),
276 0.371293971820387,
277 atol=TOLERANCE_ABSOLUTE_TESTS,
278 )
280 np.testing.assert_allclose(
281 log_encoding_FLog2(1.0),
282 0.568219370444443,
283 atol=TOLERANCE_ABSOLUTE_TESTS,
284 )
286 def test_n_dimensional_log_encoding_FLog2(self) -> None:
287 """
288 Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
289log_encoding_FLog2` definition n-dimensional arrays support.
290 """
292 L_in = 0.18
293 V_out = log_encoding_FLog2(L_in)
295 L_in = np.tile(L_in, 6)
296 V_out = np.tile(V_out, 6)
297 np.testing.assert_allclose(
298 log_encoding_FLog2(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS
299 )
301 L_in = np.reshape(L_in, (2, 3))
302 V_out = np.reshape(V_out, (2, 3))
303 np.testing.assert_allclose(
304 log_encoding_FLog2(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS
305 )
307 L_in = np.reshape(L_in, (2, 3, 1))
308 V_out = np.reshape(V_out, (2, 3, 1))
309 np.testing.assert_allclose(
310 log_encoding_FLog2(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS
311 )
313 def test_domain_range_scale_log_encoding_FLog2(self) -> None:
314 """
315 Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
316log_encoding_FLog2` definition domain and range scale support.
317 """
319 L_in = 0.18
320 V_out = log_encoding_FLog2(L_in)
322 d_r = (("reference", 1), ("1", 1), ("100", 100))
323 for scale, factor in d_r:
324 with domain_range_scale(scale):
325 np.testing.assert_array_equal(
326 log_encoding_FLog2(L_in * factor), V_out * factor
327 )
329 @ignore_numpy_errors
330 def test_nan_log_encoding_FLog2(self) -> None:
331 """
332 Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
333log_encoding_FLog2` definition nan support.
334 """
336 log_encoding_FLog2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
339class TestLogDecoding_FLog2:
340 """
341 Define :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
342log_decoding_FLog2` definition unit tests methods.
343 """
345 def test_log_decoding_FLog2(self) -> None:
346 """
347 Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
348log_decoding_FLog2` definition.
349 """
351 np.testing.assert_allclose(
352 log_decoding_FLog2(0.092864000000000),
353 0.0,
354 atol=TOLERANCE_ABSOLUTE_TESTS,
355 )
357 np.testing.assert_allclose(
358 log_decoding_FLog2(0.391007241891230),
359 0.18,
360 atol=TOLERANCE_ABSOLUTE_TESTS,
361 )
363 np.testing.assert_allclose(
364 log_decoding_FLog2(0.391007241891230, 12),
365 0.18,
366 atol=TOLERANCE_ABSOLUTE_TESTS,
367 )
369 np.testing.assert_allclose(
370 log_decoding_FLog2(0.383562110108137, 10, False),
371 0.18,
372 atol=TOLERANCE_ABSOLUTE_TESTS,
373 )
375 np.testing.assert_allclose(
376 log_decoding_FLog2(0.371293971820387, 10, False, False),
377 0.18,
378 atol=TOLERANCE_ABSOLUTE_TESTS,
379 )
381 np.testing.assert_allclose(
382 log_decoding_FLog2(0.568219370444443),
383 1.0,
384 atol=TOLERANCE_ABSOLUTE_TESTS,
385 )
387 def test_n_dimensional_log_decoding_FLog2(self) -> None:
388 """
389 Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
390log_decoding_FLog2` definition n-dimensional arrays support.
391 """
393 V_out = 0.39100724189123
394 L_in = log_decoding_FLog2(V_out)
396 V_out = np.tile(V_out, 6)
397 L_in = np.tile(L_in, 6)
398 np.testing.assert_allclose(
399 log_decoding_FLog2(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS
400 )
402 V_out = np.reshape(V_out, (2, 3))
403 L_in = np.reshape(L_in, (2, 3))
404 np.testing.assert_allclose(
405 log_decoding_FLog2(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS
406 )
408 V_out = np.reshape(V_out, (2, 3, 1))
409 L_in = np.reshape(L_in, (2, 3, 1))
410 np.testing.assert_allclose(
411 log_decoding_FLog2(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS
412 )
414 def test_domain_range_scale_log_decoding_FLog2(self) -> None:
415 """
416 Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
417log_decoding_FLog2` definition domain and range scale support.
418 """
420 V_out = 0.39100724189123
421 L_in = log_decoding_FLog2(V_out)
423 d_r = (("reference", 1), ("1", 1), ("100", 100))
424 for scale, factor in d_r:
425 with domain_range_scale(scale):
426 np.testing.assert_array_equal(
427 log_decoding_FLog2(V_out * factor),
428 L_in * factor,
429 )
431 @ignore_numpy_errors
432 def test_nan_log_decoding_FLog2(self) -> None:
433 """
434 Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\
435log_decoding_FLog2` definition nan support.
436 """
438 log_decoding_FLog2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))