Coverage for models/rgb/transfer_functions/tests/test_red.py: 100%
338 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.red` module.
4"""
6import numpy as np
8from colour.constants import TOLERANCE_ABSOLUTE_TESTS
9from colour.models.rgb.transfer_functions import (
10 log_decoding_Log3G12,
11 log_decoding_REDLog,
12 log_decoding_REDLogFilm,
13 log_encoding_Log3G12,
14 log_encoding_REDLog,
15 log_encoding_REDLogFilm,
16)
17from colour.models.rgb.transfer_functions.red import (
18 log_decoding_Log3G10_v1,
19 log_decoding_Log3G10_v2,
20 log_decoding_Log3G10_v3,
21 log_encoding_Log3G10_v1,
22 log_encoding_Log3G10_v2,
23 log_encoding_Log3G10_v3,
24)
25from colour.utilities import domain_range_scale, ignore_numpy_errors
27__author__ = "Colour Developers"
28__copyright__ = "Copyright 2013 Colour Developers"
29__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
30__maintainer__ = "Colour Developers"
31__email__ = "colour-developers@colour-science.org"
32__status__ = "Development"
34__all__ = [
35 "TestLogEncoding_REDLog",
36 "TestLogDecoding_REDLog",
37 "TestLogEncoding_REDLogFilm",
38 "TestLogDecoding_REDLogFilm",
39 "TestLogEncoding_Log3G10_v1",
40 "TestLogDecoding_Log3G10_v1",
41 "TestLogEncoding_Log3G10_v2",
42 "TestLogDecoding_Log3G10_v2",
43 "TestLogEncoding_Log3G10_v3",
44 "TestLogDecoding_Log3G10_v3",
45 "TestLogEncoding_Log3G12",
46 "TestLogDecoding_Log3G12",
47]
50class TestLogEncoding_REDLog:
51 """
52 Define :func:`colour.models.rgb.transfer_functions.red.\
53log_encoding_REDLog` definition unit tests methods.
54 """
56 def test_log_encoding_REDLog(self) -> None:
57 """
58 Test :func:`colour.models.rgb.transfer_functions.red.\
59log_encoding_REDLog` definition.
60 """
62 np.testing.assert_allclose(
63 log_encoding_REDLog(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS
64 )
66 np.testing.assert_allclose(
67 log_encoding_REDLog(0.18),
68 0.637621845988175,
69 atol=TOLERANCE_ABSOLUTE_TESTS,
70 )
72 np.testing.assert_allclose(
73 log_encoding_REDLog(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS
74 )
76 def test_n_dimensional_log_encoding_REDLog(self) -> None:
77 """
78 Test :func:`colour.models.rgb.transfer_functions.red.\
79log_encoding_REDLog` definition n-dimensional arrays support.
80 """
82 x = 0.18
83 y = log_encoding_REDLog(x)
85 x = np.tile(x, 6)
86 y = np.tile(y, 6)
87 np.testing.assert_allclose(
88 log_encoding_REDLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
89 )
91 x = np.reshape(x, (2, 3))
92 y = np.reshape(y, (2, 3))
93 np.testing.assert_allclose(
94 log_encoding_REDLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
95 )
97 x = np.reshape(x, (2, 3, 1))
98 y = np.reshape(y, (2, 3, 1))
99 np.testing.assert_allclose(
100 log_encoding_REDLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
101 )
103 def test_domain_range_scale_log_encoding_REDLog(self) -> None:
104 """
105 Test :func:`colour.models.rgb.transfer_functions.red.\
106log_encoding_REDLog` definition domain and range scale support.
107 """
109 x = 0.18
110 y = log_encoding_REDLog(x)
112 d_r = (("reference", 1), ("1", 1), ("100", 100))
113 for scale, factor in d_r:
114 with domain_range_scale(scale):
115 np.testing.assert_allclose(
116 log_encoding_REDLog(x * factor),
117 y * factor,
118 atol=TOLERANCE_ABSOLUTE_TESTS,
119 )
121 @ignore_numpy_errors
122 def test_nan_log_encoding_REDLog(self) -> None:
123 """
124 Test :func:`colour.models.rgb.transfer_functions.red.\
125log_encoding_REDLog` definition nan support.
126 """
128 log_encoding_REDLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
131class TestLogDecoding_REDLog:
132 """
133 Define :func:`colour.models.rgb.transfer_functions.red.\
134log_decoding_REDLog` definition unit tests methods.
135 """
137 def test_log_decoding_REDLog(self) -> None:
138 """
139 Test :func:`colour.models.rgb.transfer_functions.red.\
140log_decoding_REDLog` definition.
141 """
143 np.testing.assert_allclose(
144 log_decoding_REDLog(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS
145 )
147 np.testing.assert_allclose(
148 log_decoding_REDLog(0.637621845988175),
149 0.18,
150 atol=TOLERANCE_ABSOLUTE_TESTS,
151 )
153 np.testing.assert_allclose(
154 log_decoding_REDLog(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS
155 )
157 def test_n_dimensional_log_decoding_REDLog(self) -> None:
158 """
159 Test :func:`colour.models.rgb.transfer_functions.red.\
160log_decoding_REDLog` definition n-dimensional arrays support.
161 """
163 y = 0.637621845988175
164 x = log_decoding_REDLog(y)
166 y = np.tile(y, 6)
167 x = np.tile(x, 6)
168 np.testing.assert_allclose(
169 log_decoding_REDLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
170 )
172 y = np.reshape(y, (2, 3))
173 x = np.reshape(x, (2, 3))
174 np.testing.assert_allclose(
175 log_decoding_REDLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
176 )
178 y = np.reshape(y, (2, 3, 1))
179 x = np.reshape(x, (2, 3, 1))
180 np.testing.assert_allclose(
181 log_decoding_REDLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
182 )
184 def test_domain_range_scale_log_decoding_REDLog(self) -> None:
185 """
186 Test :func:`colour.models.rgb.transfer_functions.red.\
187log_decoding_REDLog` definition domain and range scale support.
188 """
190 y = 0.637621845988175
191 x = log_decoding_REDLog(y)
193 d_r = (("reference", 1), ("1", 1), ("100", 100))
194 for scale, factor in d_r:
195 with domain_range_scale(scale):
196 np.testing.assert_allclose(
197 log_decoding_REDLog(y * factor),
198 x * factor,
199 atol=TOLERANCE_ABSOLUTE_TESTS,
200 )
202 @ignore_numpy_errors
203 def test_nan_log_decoding_REDLog(self) -> None:
204 """
205 Test :func:`colour.models.rgb.transfer_functions.red.\
206log_decoding_REDLog` definition nan support.
207 """
209 log_decoding_REDLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
212class TestLogEncoding_REDLogFilm:
213 """
214 Define :func:`colour.models.rgb.transfer_functions.red.\
215log_encoding_REDLogFilm` definition unit tests methods.
216 """
218 def test_log_encoding_REDLogFilm(self) -> None:
219 """
220 Test :func:`colour.models.rgb.transfer_functions.red.\
221log_encoding_REDLogFilm` definition.
222 """
224 np.testing.assert_allclose(
225 log_encoding_REDLogFilm(0.0),
226 0.092864125122190,
227 atol=TOLERANCE_ABSOLUTE_TESTS,
228 )
230 np.testing.assert_allclose(
231 log_encoding_REDLogFilm(0.18),
232 0.457319613085418,
233 atol=TOLERANCE_ABSOLUTE_TESTS,
234 )
236 np.testing.assert_allclose(
237 log_encoding_REDLogFilm(1.0),
238 0.669599217986315,
239 atol=TOLERANCE_ABSOLUTE_TESTS,
240 )
242 def test_n_dimensional_log_encoding_REDLogFilm(self) -> None:
243 """
244 Test :func:`colour.models.rgb.transfer_functions.red.\
245log_encoding_REDLogFilm` definition n-dimensional arrays support.
246 """
248 x = 0.18
249 y = log_encoding_REDLogFilm(x)
251 x = np.tile(x, 6)
252 y = np.tile(y, 6)
253 np.testing.assert_allclose(
254 log_encoding_REDLogFilm(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
255 )
257 x = np.reshape(x, (2, 3))
258 y = np.reshape(y, (2, 3))
259 np.testing.assert_allclose(
260 log_encoding_REDLogFilm(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
261 )
263 x = np.reshape(x, (2, 3, 1))
264 y = np.reshape(y, (2, 3, 1))
265 np.testing.assert_allclose(
266 log_encoding_REDLogFilm(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
267 )
269 def test_domain_range_scale_log_encoding_REDLogFilm(self) -> None:
270 """
271 Test :func:`colour.models.rgb.transfer_functions.red.\
272log_encoding_REDLogFilm` definition domain and range scale support.
273 """
275 x = 0.18
276 y = log_encoding_REDLogFilm(x)
278 d_r = (("reference", 1), ("1", 1), ("100", 100))
279 for scale, factor in d_r:
280 with domain_range_scale(scale):
281 np.testing.assert_allclose(
282 log_encoding_REDLogFilm(x * factor),
283 y * factor,
284 atol=TOLERANCE_ABSOLUTE_TESTS,
285 )
287 @ignore_numpy_errors
288 def test_nan_log_encoding_REDLogFilm(self) -> None:
289 """
290 Test :func:`colour.models.rgb.transfer_functions.red.\
291log_encoding_REDLogFilm` definition nan support.
292 """
294 log_encoding_REDLogFilm(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
297class TestLogDecoding_REDLogFilm:
298 """
299 Define :func:`colour.models.rgb.transfer_functions.red.\
300log_decoding_REDLogFilm` definition unit tests methods.
301 """
303 def test_log_decoding_REDLogFilm(self) -> None:
304 """
305 Test :func:`colour.models.rgb.transfer_functions.red.\
306log_decoding_REDLogFilm` definition.
307 """
309 np.testing.assert_allclose(
310 log_decoding_REDLogFilm(0.092864125122190),
311 0.0,
312 atol=TOLERANCE_ABSOLUTE_TESTS,
313 )
315 np.testing.assert_allclose(
316 log_decoding_REDLogFilm(0.457319613085418),
317 0.18,
318 atol=TOLERANCE_ABSOLUTE_TESTS,
319 )
321 np.testing.assert_allclose(
322 log_decoding_REDLogFilm(0.669599217986315),
323 1.0,
324 atol=TOLERANCE_ABSOLUTE_TESTS,
325 )
327 def test_n_dimensional_log_decoding_REDLogFilm(self) -> None:
328 """
329 Test :func:`colour.models.rgb.transfer_functions.red.\
330log_decoding_REDLogFilm` definition n-dimensional arrays support.
331 """
333 y = 0.457319613085418
334 x = log_decoding_REDLogFilm(y)
336 y = np.tile(y, 6)
337 x = np.tile(x, 6)
338 np.testing.assert_allclose(
339 log_decoding_REDLogFilm(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
340 )
342 y = np.reshape(y, (2, 3))
343 x = np.reshape(x, (2, 3))
344 np.testing.assert_allclose(
345 log_decoding_REDLogFilm(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
346 )
348 y = np.reshape(y, (2, 3, 1))
349 x = np.reshape(x, (2, 3, 1))
350 np.testing.assert_allclose(
351 log_decoding_REDLogFilm(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
352 )
354 def test_domain_range_scale_log_decoding_REDLogFilm(self) -> None:
355 """
356 Test :func:`colour.models.rgb.transfer_functions.red.\
357log_decoding_REDLogFilm` definition domain and range scale support.
358 """
360 y = 0.457319613085418
361 x = log_decoding_REDLogFilm(y)
363 d_r = (("reference", 1), ("1", 1), ("100", 100))
364 for scale, factor in d_r:
365 with domain_range_scale(scale):
366 np.testing.assert_allclose(
367 log_decoding_REDLogFilm(y * factor),
368 x * factor,
369 atol=TOLERANCE_ABSOLUTE_TESTS,
370 )
372 @ignore_numpy_errors
373 def test_nan_log_decoding_REDLogFilm(self) -> None:
374 """
375 Test :func:`colour.models.rgb.transfer_functions.red.\
376log_decoding_REDLogFilm` definition nan support.
377 """
379 log_decoding_REDLogFilm(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
382class TestLogEncoding_Log3G10_v1:
383 """
384 Define :func:`colour.models.rgb.transfer_functions.red.\
385log_encoding_Log3G10_v1` definition unit tests methods.
386 """
388 def test_log_encoding_Log3G10_v1(self) -> None:
389 """
390 Test :func:`colour.models.rgb.transfer_functions.red.\
391log_encoding_Log3G10_v1` definition.
392 """
394 np.testing.assert_allclose(
395 log_encoding_Log3G10_v1(-1.0),
396 -0.496483569056003,
397 atol=TOLERANCE_ABSOLUTE_TESTS,
398 )
400 np.testing.assert_allclose(
401 log_encoding_Log3G10_v1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS
402 )
404 np.testing.assert_allclose(
405 log_encoding_Log3G10_v1(0.18),
406 0.333333644207707,
407 atol=TOLERANCE_ABSOLUTE_TESTS,
408 )
410 def test_n_dimensional_log_encoding_Log3G10_v1(self) -> None:
411 """
412 Test :func:`colour.models.rgb.transfer_functions.red.\
413log_encoding_Log3G10_v1` definition n-dimensional arrays support.
414 """
416 x = 0.18
417 y = log_encoding_Log3G10_v1(x)
419 x = np.tile(x, 6)
420 y = np.tile(y, 6)
421 np.testing.assert_allclose(
422 log_encoding_Log3G10_v1(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
423 )
425 x = np.reshape(x, (2, 3))
426 y = np.reshape(y, (2, 3))
427 np.testing.assert_allclose(
428 log_encoding_Log3G10_v1(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
429 )
431 x = np.reshape(x, (2, 3, 1))
432 y = np.reshape(y, (2, 3, 1))
433 np.testing.assert_allclose(
434 log_encoding_Log3G10_v1(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
435 )
437 def test_domain_range_scale_log_encoding_Log3G10_v1(self) -> None:
438 """
439 Test :func:`colour.models.rgb.transfer_functions.red.\
440log_encoding_Log3G10_v1` definition domain and range scale support.
441 """
443 x = 0.18
444 y = log_encoding_Log3G10_v1(x)
446 d_r = (("reference", 1), ("1", 1), ("100", 100))
447 for scale, factor in d_r:
448 with domain_range_scale(scale):
449 np.testing.assert_allclose(
450 log_encoding_Log3G10_v1(x * factor),
451 y * factor,
452 atol=TOLERANCE_ABSOLUTE_TESTS,
453 )
455 @ignore_numpy_errors
456 def test_nan_log_encoding_Log3G10_v1(self) -> None:
457 """
458 Test :func:`colour.models.rgb.transfer_functions.red.\
459log_encoding_Log3G10_v1` definition nan support.
460 """
462 log_encoding_Log3G10_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
465class TestLogDecoding_Log3G10_v1:
466 """
467 Define :func:`colour.models.rgb.transfer_functions.red.\
468log_decoding_Log3G10_v1` definition unit tests methods.
469 """
471 def test_log_decoding_Log3G10_v1(self) -> None:
472 """
473 Test :func:`colour.models.rgb.transfer_functions.red.\
474log_decoding_Log3G10_v1` definition.
475 """
477 np.testing.assert_allclose(
478 log_decoding_Log3G10_v1(-0.496483569056003),
479 -1.0,
480 atol=TOLERANCE_ABSOLUTE_TESTS,
481 )
483 np.testing.assert_allclose(
484 log_decoding_Log3G10_v1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS
485 )
487 np.testing.assert_allclose(
488 log_decoding_Log3G10_v1(0.333333644207707),
489 0.18,
490 atol=TOLERANCE_ABSOLUTE_TESTS,
491 )
493 def test_n_dimensional_log_decoding_Log3G10_v1(self) -> None:
494 """
495 Test :func:`colour.models.rgb.transfer_functions.red.\
496log_decoding_Log3G10_v1` definition n-dimensional arrays support.
497 """
499 y = 0.333333644207707
500 x = log_decoding_Log3G10_v1(y)
502 y = np.tile(y, 6)
503 x = np.tile(x, 6)
504 np.testing.assert_allclose(
505 log_decoding_Log3G10_v1(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
506 )
508 y = np.reshape(y, (2, 3))
509 x = np.reshape(x, (2, 3))
510 np.testing.assert_allclose(
511 log_decoding_Log3G10_v1(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
512 )
514 y = np.reshape(y, (2, 3, 1))
515 x = np.reshape(x, (2, 3, 1))
516 np.testing.assert_allclose(
517 log_decoding_Log3G10_v1(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
518 )
520 def test_domain_range_scale_log_decoding_Log3G10_v1(self) -> None:
521 """
522 Test :func:`colour.models.rgb.transfer_functions.red.\
523log_decoding_Log3G10_v1` definition domain and range scale support.
524 """
526 y = 0.333333644207707
527 x = log_decoding_Log3G10_v1(y)
529 d_r = (("reference", 1), ("1", 1), ("100", 100))
530 for scale, factor in d_r:
531 with domain_range_scale(scale):
532 np.testing.assert_allclose(
533 log_decoding_Log3G10_v1(y * factor),
534 x * factor,
535 atol=TOLERANCE_ABSOLUTE_TESTS,
536 )
538 @ignore_numpy_errors
539 def test_nan_log_decoding_Log3G10_v1(self) -> None:
540 """
541 Test :func:`colour.models.rgb.transfer_functions.red.\
542log_decoding_Log3G10_v1` definition nan support.
543 """
545 log_decoding_Log3G10_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
548class TestLogEncoding_Log3G10_v2:
549 """
550 Define :func:`colour.models.rgb.transfer_functions.red.\
551log_encoding_Log3G10_v2` definition unit tests methods.
552 """
554 def test_log_encoding_Log3G10_v2(self) -> None:
555 """
556 Test :func:`colour.models.rgb.transfer_functions.red.\
557log_encoding_Log3G10_v2` definition.
558 """
560 np.testing.assert_allclose(
561 log_encoding_Log3G10_v2(-1.0),
562 -0.491512777522511,
563 atol=TOLERANCE_ABSOLUTE_TESTS,
564 )
566 np.testing.assert_allclose(
567 log_encoding_Log3G10_v2(0.0),
568 0.091551487714745,
569 atol=TOLERANCE_ABSOLUTE_TESTS,
570 )
572 np.testing.assert_allclose(
573 log_encoding_Log3G10_v2(0.18),
574 0.333332912025992,
575 atol=TOLERANCE_ABSOLUTE_TESTS,
576 )
578 def test_n_dimensional_log_encoding_Log3G10_v2(self) -> None:
579 """
580 Test :func:`colour.models.rgb.transfer_functions.red.\
581log_encoding_Log3G10_v2` definition n-dimensional arrays support.
582 """
584 x = 0.18
585 y = log_encoding_Log3G10_v2(x)
587 x = np.tile(x, 6)
588 y = np.tile(y, 6)
589 np.testing.assert_allclose(
590 log_encoding_Log3G10_v2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
591 )
593 x = np.reshape(x, (2, 3))
594 y = np.reshape(y, (2, 3))
595 np.testing.assert_allclose(
596 log_encoding_Log3G10_v2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
597 )
599 x = np.reshape(x, (2, 3, 1))
600 y = np.reshape(y, (2, 3, 1))
601 np.testing.assert_allclose(
602 log_encoding_Log3G10_v2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
603 )
605 def test_domain_range_scale_log_encoding_Log3G10_v2(self) -> None:
606 """
607 Test :func:`colour.models.rgb.transfer_functions.red.\
608log_encoding_Log3G10_v2` definition domain and range scale support.
609 """
611 x = 0.18
612 y = log_encoding_Log3G10_v2(x)
614 d_r = (("reference", 1), ("1", 1), ("100", 100))
615 for scale, factor in d_r:
616 with domain_range_scale(scale):
617 np.testing.assert_allclose(
618 log_encoding_Log3G10_v2(x * factor),
619 y * factor,
620 atol=TOLERANCE_ABSOLUTE_TESTS,
621 )
623 @ignore_numpy_errors
624 def test_nan_log_encoding_Log3G10_v2(self) -> None:
625 """
626 Test :func:`colour.models.rgb.transfer_functions.red.\
627log_encoding_Log3G10_v2` definition nan support.
628 """
630 log_encoding_Log3G10_v2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
633class TestLogDecoding_Log3G10_v2:
634 """
635 Define :func:`colour.models.rgb.transfer_functions.red.\
636log_decoding_Log3G10_v2` definition unit tests methods.
637 """
639 def test_log_decoding_Log3G10_v2(self) -> None:
640 """
641 Test :func:`colour.models.rgb.transfer_functions.red.\
642log_decoding_Log3G10_v2` definition.
643 """
645 np.testing.assert_allclose(
646 log_decoding_Log3G10_v2(-0.491512777522511),
647 -1.0,
648 atol=TOLERANCE_ABSOLUTE_TESTS,
649 )
651 np.testing.assert_allclose(
652 log_decoding_Log3G10_v2(0.091551487714745),
653 0.0,
654 atol=TOLERANCE_ABSOLUTE_TESTS,
655 )
657 np.testing.assert_allclose(
658 log_decoding_Log3G10_v2(0.333332912025992),
659 0.18,
660 atol=TOLERANCE_ABSOLUTE_TESTS,
661 )
663 def test_n_dimensional_log_decoding_Log3G10_v2(self) -> None:
664 """
665 Test :func:`colour.models.rgb.transfer_functions.red.\
666log_decoding_Log3G10_v2` definition n-dimensional arrays support.
667 """
669 y = 0.333332912025992
670 x = log_decoding_Log3G10_v2(y)
672 y = np.tile(y, 6)
673 x = np.tile(x, 6)
674 np.testing.assert_allclose(
675 log_decoding_Log3G10_v2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
676 )
678 y = np.reshape(y, (2, 3))
679 x = np.reshape(x, (2, 3))
680 np.testing.assert_allclose(
681 log_decoding_Log3G10_v2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
682 )
684 y = np.reshape(y, (2, 3, 1))
685 x = np.reshape(x, (2, 3, 1))
686 np.testing.assert_allclose(
687 log_decoding_Log3G10_v2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
688 )
690 def test_domain_range_scale_log_decoding_Log3G10_v2(self) -> None:
691 """
692 Test :func:`colour.models.rgb.transfer_functions.red.\
693log_decoding_Log3G10_v2` definition domain and range scale support.
694 """
696 y = 0.333333644207707
697 x = log_decoding_Log3G10_v2(y)
699 d_r = (("reference", 1), ("1", 1), ("100", 100))
700 for scale, factor in d_r:
701 with domain_range_scale(scale):
702 np.testing.assert_allclose(
703 log_decoding_Log3G10_v2(y * factor),
704 x * factor,
705 atol=TOLERANCE_ABSOLUTE_TESTS,
706 )
708 @ignore_numpy_errors
709 def test_nan_log_decoding_Log3G10_v2(self) -> None:
710 """
711 Test :func:`colour.models.rgb.transfer_functions.red.\
712log_decoding_Log3G10_v2` definition nan support.
713 """
715 log_decoding_Log3G10_v2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
718class TestLogEncoding_Log3G10_v3:
719 """
720 Define :func:`colour.models.rgb.transfer_functions.red.\
721log_encoding_Log3G10_v3` definition unit tests methods.
722 """
724 def test_log_encoding_Log3G10_v3(self) -> None:
725 """
726 Test :func:`colour.models.rgb.transfer_functions.red.\
727log_encoding_Log3G10_v3` definition.
728 """
730 np.testing.assert_allclose(
731 log_encoding_Log3G10_v3(-1.0),
732 -15.040773,
733 atol=TOLERANCE_ABSOLUTE_TESTS,
734 )
736 np.testing.assert_allclose(
737 log_encoding_Log3G10_v3(0.0),
738 0.091551487714745,
739 atol=TOLERANCE_ABSOLUTE_TESTS,
740 )
742 np.testing.assert_allclose(
743 log_encoding_Log3G10_v3(0.18),
744 0.333332912025992,
745 atol=TOLERANCE_ABSOLUTE_TESTS,
746 )
748 def test_n_dimensional_log_encoding_Log3G10_v3(self) -> None:
749 """
750 Test :func:`colour.models.rgb.transfer_functions.red.\
751log_encoding_Log3G10_v3` definition n-dimensional arrays support.
752 """
754 x = 0.18
755 y = log_encoding_Log3G10_v3(x)
757 x = np.tile(x, 6)
758 y = np.tile(y, 6)
759 np.testing.assert_allclose(
760 log_encoding_Log3G10_v3(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
761 )
763 x = np.reshape(x, (2, 3))
764 y = np.reshape(y, (2, 3))
765 np.testing.assert_allclose(
766 log_encoding_Log3G10_v3(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
767 )
769 x = np.reshape(x, (2, 3, 1))
770 y = np.reshape(y, (2, 3, 1))
771 np.testing.assert_allclose(
772 log_encoding_Log3G10_v3(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
773 )
775 def test_domain_range_scale_log_encoding_Log3G10_v3(self) -> None:
776 """
777 Test :func:`colour.models.rgb.transfer_functions.red.\
778log_encoding_Log3G10_v3` definition domain and range scale support.
779 """
781 x = 0.18
782 y = log_encoding_Log3G10_v3(x)
784 d_r = (("reference", 1), ("1", 1), ("100", 100))
785 for scale, factor in d_r:
786 with domain_range_scale(scale):
787 np.testing.assert_allclose(
788 log_encoding_Log3G10_v3(x * factor),
789 y * factor,
790 atol=TOLERANCE_ABSOLUTE_TESTS,
791 )
793 @ignore_numpy_errors
794 def test_nan_log_encoding_Log3G10_v3(self) -> None:
795 """
796 Test :func:`colour.models.rgb.transfer_functions.red.\
797log_encoding_Log3G10_v3` definition nan support.
798 """
800 log_encoding_Log3G10_v3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
803class TestLogDecoding_Log3G10_v3:
804 """
805 Define :func:`colour.models.rgb.transfer_functions.red.\
806log_decoding_Log3G10_v3` definition unit tests methods.
807 """
809 def test_log_decoding_Log3G10_v3(self) -> None:
810 """
811 Test :func:`colour.models.rgb.transfer_functions.red.\
812log_decoding_Log3G10_v3` definition.
813 """
815 np.testing.assert_allclose(
816 log_decoding_Log3G10_v3(-15.040773),
817 -1.0,
818 atol=TOLERANCE_ABSOLUTE_TESTS,
819 )
821 np.testing.assert_allclose(
822 log_decoding_Log3G10_v3(0.091551487714745),
823 0.0,
824 atol=TOLERANCE_ABSOLUTE_TESTS,
825 )
827 np.testing.assert_allclose(
828 log_decoding_Log3G10_v3(0.333332912025992),
829 0.18,
830 atol=TOLERANCE_ABSOLUTE_TESTS,
831 )
833 def test_n_dimensional_log_decoding_Log3G10_v3(self) -> None:
834 """
835 Test :func:`colour.models.rgb.transfer_functions.red.\
836log_decoding_Log3G10_v3` definition n-dimensional arrays support.
837 """
839 y = 0.333332912025992
840 x = log_decoding_Log3G10_v3(y)
842 y = np.tile(y, 6)
843 x = np.tile(x, 6)
844 np.testing.assert_allclose(
845 log_decoding_Log3G10_v3(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
846 )
848 y = np.reshape(y, (2, 3))
849 x = np.reshape(x, (2, 3))
850 np.testing.assert_allclose(
851 log_decoding_Log3G10_v3(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
852 )
854 y = np.reshape(y, (2, 3, 1))
855 x = np.reshape(x, (2, 3, 1))
856 np.testing.assert_allclose(
857 log_decoding_Log3G10_v3(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
858 )
860 def test_domain_range_scale_log_decoding_Log3G10_v3(self) -> None:
861 """
862 Test :func:`colour.models.rgb.transfer_functions.red.\
863log_decoding_Log3G10_v3` definition domain and range scale support.
864 """
866 y = 0.333333644207707
867 x = log_decoding_Log3G10_v3(y)
869 d_r = (("reference", 1), ("1", 1), ("100", 100))
870 for scale, factor in d_r:
871 with domain_range_scale(scale):
872 np.testing.assert_allclose(
873 log_decoding_Log3G10_v3(y * factor),
874 x * factor,
875 atol=TOLERANCE_ABSOLUTE_TESTS,
876 )
878 @ignore_numpy_errors
879 def test_nan_log_decoding_Log3G10_v3(self) -> None:
880 """
881 Test :func:`colour.models.rgb.transfer_functions.red.\
882log_decoding_Log3G10_v3` definition nan support.
883 """
885 log_decoding_Log3G10_v3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
888class TestLogEncoding_Log3G12:
889 """
890 Define :func:`colour.models.rgb.transfer_functions.red.\
891log_encoding_Log3G12` definition unit tests methods.
892 """
894 def test_log_encoding_Log3G12(self) -> None:
895 """
896 Test :func:`colour.models.rgb.transfer_functions.red.\
897log_encoding_Log3G12` definition.
898 """
900 np.testing.assert_allclose(
901 log_encoding_Log3G12(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS
902 )
904 np.testing.assert_allclose(
905 log_encoding_Log3G12(0.18),
906 0.333332662015923,
907 atol=TOLERANCE_ABSOLUTE_TESTS,
908 )
910 np.testing.assert_allclose(
911 log_encoding_Log3G12(1.0),
912 0.469991923234319,
913 atol=TOLERANCE_ABSOLUTE_TESTS,
914 )
916 np.testing.assert_allclose(
917 log_encoding_Log3G12(0.18 * 2**12),
918 0.999997986792394,
919 atol=TOLERANCE_ABSOLUTE_TESTS,
920 )
922 def test_n_dimensional_log_encoding_Log3G12(self) -> None:
923 """
924 Test :func:`colour.models.rgb.transfer_functions.red.\
925log_encoding_Log3G12` definition n-dimensional arrays support.
926 """
928 x = 0.18
929 y = log_encoding_Log3G12(x)
931 x = np.tile(x, 6)
932 y = np.tile(y, 6)
933 np.testing.assert_allclose(
934 log_encoding_Log3G12(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
935 )
937 x = np.reshape(x, (2, 3))
938 y = np.reshape(y, (2, 3))
939 np.testing.assert_allclose(
940 log_encoding_Log3G12(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
941 )
943 x = np.reshape(x, (2, 3, 1))
944 y = np.reshape(y, (2, 3, 1))
945 np.testing.assert_allclose(
946 log_encoding_Log3G12(x), y, atol=TOLERANCE_ABSOLUTE_TESTS
947 )
949 def test_domain_range_scale_log_encoding_Log3G12(self) -> None:
950 """
951 Test :func:`colour.models.rgb.transfer_functions.red.\
952log_encoding_Log3G12` definition domain and range scale support.
953 """
955 x = 0.18
956 y = log_encoding_Log3G12(x)
958 d_r = (("reference", 1), ("1", 1), ("100", 100))
959 for scale, factor in d_r:
960 with domain_range_scale(scale):
961 np.testing.assert_allclose(
962 log_encoding_Log3G12(x * factor),
963 y * factor,
964 atol=TOLERANCE_ABSOLUTE_TESTS,
965 )
967 @ignore_numpy_errors
968 def test_nan_log_encoding_Log3G12(self) -> None:
969 """
970 Test :func:`colour.models.rgb.transfer_functions.red.\
971log_encoding_Log3G12` definition nan support.
972 """
974 log_encoding_Log3G12(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
977class TestLogDecoding_Log3G12:
978 """
979 Define :func:`colour.models.rgb.transfer_functions.red.\
980log_decoding_Log3G12` definition unit tests methods.
981 """
983 def test_log_decoding_Log3G12(self) -> None:
984 """
985 Test :func:`colour.models.rgb.transfer_functions.red.\
986log_decoding_Log3G12` definition.
987 """
989 np.testing.assert_allclose(
990 log_decoding_Log3G12(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS
991 )
993 np.testing.assert_allclose(
994 log_decoding_Log3G12(0.333332662015923),
995 0.18,
996 atol=TOLERANCE_ABSOLUTE_TESTS,
997 )
999 np.testing.assert_allclose(
1000 log_decoding_Log3G12(0.469991923234319),
1001 1.0,
1002 atol=TOLERANCE_ABSOLUTE_TESTS,
1003 )
1005 np.testing.assert_allclose(
1006 log_decoding_Log3G12(1.0),
1007 737.29848406719,
1008 atol=TOLERANCE_ABSOLUTE_TESTS,
1009 )
1011 def test_n_dimensional_log_decoding_Log3G12(self) -> None:
1012 """
1013 Test :func:`colour.models.rgb.transfer_functions.red.\
1014log_decoding_Log3G12` definition n-dimensional arrays support.
1015 """
1017 y = 0.333332662015923
1018 x = log_decoding_Log3G12(y)
1020 y = np.tile(y, 6)
1021 x = np.tile(x, 6)
1022 np.testing.assert_allclose(
1023 log_decoding_Log3G12(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
1024 )
1026 y = np.reshape(y, (2, 3))
1027 x = np.reshape(x, (2, 3))
1028 np.testing.assert_allclose(
1029 log_decoding_Log3G12(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
1030 )
1032 y = np.reshape(y, (2, 3, 1))
1033 x = np.reshape(x, (2, 3, 1))
1034 np.testing.assert_allclose(
1035 log_decoding_Log3G12(y), x, atol=TOLERANCE_ABSOLUTE_TESTS
1036 )
1038 def test_domain_range_scale_log_decoding_Log3G12(self) -> None:
1039 """
1040 Test :func:`colour.models.rgb.transfer_functions.red.\
1041log_decoding_Log3G12` definition domain and range scale support.
1042 """
1044 y = 0.18
1045 x = log_decoding_Log3G12(y)
1047 d_r = (("reference", 1), ("1", 1), ("100", 100))
1048 for scale, factor in d_r:
1049 with domain_range_scale(scale):
1050 np.testing.assert_allclose(
1051 log_decoding_Log3G12(y * factor),
1052 x * factor,
1053 atol=TOLERANCE_ABSOLUTE_TESTS,
1054 )
1056 @ignore_numpy_errors
1057 def test_nan_log_decoding_Log3G12(self) -> None:
1058 """
1059 Test :func:`colour.models.rgb.transfer_functions.red.\
1060log_decoding_Log3G12` definition nan support.
1061 """
1063 log_decoding_Log3G12(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))