Coverage for models/tests/test_cam16_ucs.py: 100%

1"""Define the unit tests for the :mod:`colour.models.cam16_ucs` module."""

2

3 from __future__ import annotations

4

5 import numpy as np

6

7 from colour.constants import TOLERANCE_ABSOLUTE_TESTS

8 from colour.models.cam02_ucs import COEFFICIENTS_UCS_LUO2006

9 from colour.models.cam16_ucs import (

10 UCS_Li2017_to_XYZ,

11 XYZ_to_UCS_Li2017,

12)

13 from colour.models.tests.test_cam02_ucs import (

14 TestJMh_CIECAM02_to_UCS_Luo2006,

15 TestUCS_Luo2006_to_JMh_CIECAM02,

16 TestUCS_Luo2006_to_XYZ,

17 TestXYZ_to_UCS_Luo2006,

18)

19

20 __author__ = "Colour Developers"

21 __copyright__ = "Copyright 2013 Colour Developers"

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

23 __maintainer__ = "Colour Developers"

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

25 __status__ = "Production"

26

27 __all__ = [

28 "TestJMh_CAM16_to_UCS_Li2017",

29 "TestUCS_Li2017_to_JMh_CAM16",

30 "TestXYZ_to_UCS_Li2017",

31 "TestUCS_Li2017_to_XYZ",

32]

33

34

35 class TestJMh_CAM16_to_UCS_Li2017(TestJMh_CIECAM02_to_UCS_Luo2006):

36 """

37 Define :func:`colour.models.cam16_ucs.JMh_CAM16_to_UCS_Li2017`

38 definition unit tests methods.

39

40 Notes

41 -----

42 - :func:`colour.models.cam16_ucs.JMh_CAM16_to_UCS_Li2017` is a wrapper

43 of :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006` and thus

44 currently adopts the same unittests.

45 """

46

47

48 class TestUCS_Li2017_to_JMh_CAM16(TestUCS_Luo2006_to_JMh_CIECAM02):

49 """

50 Define :func:`colour.models.cam16_ucs.UCS_Li2017_to_JMh_CAM16`

51 definition unit tests methods.

52

53 Notes

54 -----

55 - :func:`colour.models.cam16_ucs.UCS_Li2017_to_JMh_CAM16` is a wrapper

56 of :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02` and thus

57 currently adopts the same unittests.

58 """

59

60

61 class TestXYZ_to_UCS_Li2017(TestXYZ_to_UCS_Luo2006):

62 """

63 Define :func:`colour.models.cam16_ucs.XYZ_to_UCS_Li2017`

64 definition unit tests methods.

65 """

66

67 def test_XYZ_to_UCS_Li2017(self) -> None:

68 """Test :func:`colour.models.cam16_ucs.XYZ_to_UCS_Li2017` definition."""

69

70 np.testing.assert_allclose(

71 XYZ_to_UCS_Li2017(

72 np.array([0.20654008, 0.12197225, 0.05136952]),

73 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

74 ),

75 np.array([46.06586033, 41.07586491, 14.51025826]),

76 atol=TOLERANCE_ABSOLUTE_TESTS,

77 )

78

79 np.testing.assert_allclose(

80 XYZ_to_UCS_Li2017(

81 np.array([0.20654008, 0.12197225, 0.05136952]),

82 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

83 XYZ_w=np.array([0.95047, 1.0, 1.08883]),

84 ),

85 np.array([46.06573617, 41.07444159, 14.50807598]),

86 atol=TOLERANCE_ABSOLUTE_TESTS,

87 )

88

89

90 class TestUCS_Li2017_to_XYZ(TestUCS_Luo2006_to_XYZ):

91 """

92 Define :func:`colour.models.cam16_ucs.UCS_Li2017_to_XYZ`

93 definition unit tests methods.

94 """

95

96 def test_UCS_Li2017_to_XYZ(self) -> None:

97 """Test :func:`colour.models.cam16_ucs.UCS_Li2017_to_XYZ` definition."""

98

99 np.testing.assert_allclose(

100 UCS_Li2017_to_XYZ(

101 np.array([46.06586033, 41.07586491, 14.51025826]),

102 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

103 ),

104 np.array([0.20654008, 0.12197225, 0.05136952]),

105 atol=TOLERANCE_ABSOLUTE_TESTS,

106 )

107

108 np.testing.assert_allclose(

109 UCS_Li2017_to_XYZ(

110 np.array([46.06586033, 41.07586491, 14.51025826]),

111 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

112 XYZ_w=np.array([0.95047, 1.0, 1.08883]),

113 ),

114 np.array([0.2065444, 0.12197263, 0.05136016]),

115 atol=TOLERANCE_ABSOLUTE_TESTS,

116 )