Coverage for difference/tests/test__init__.py: 100%

1"""Define the unit tests for the :mod:`colour.difference` 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.difference import delta_E

9 from colour.utilities import domain_range_scale

10

11 __author__ = "Colour Developers"

12 __copyright__ = "Copyright 2013 Colour Developers"

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

14 __maintainer__ = "Colour Developers"

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

16 __status__ = "Production"

17

18 __all__ = [

19 "TestDelta_E",

20]

21

22

23 class TestDelta_E:

24 """Define :func:`colour.difference.delta_E` definition unit tests methods."""

25

26 def test_domain_range_scale_delta_E(self) -> None:

27 """

28 Test :func:`colour.difference.delta_E` definition domain and range

29 scale support.

30 """

31

32 Lab_1 = np.array([48.99183622, -0.10561667, 400.65619925])

33 Lab_2 = np.array([50.65907324, -0.11671910, 402.82235718])

34

35 m = ("CIE 1976", "CIE 1994", "CIE 2000", "CMC", "DIN99")

36 v = [delta_E(Lab_1, Lab_2, method) for method in m]

37

38 d_r = (("reference", 1), ("1", 0.01), ("100", 1))

39 for method, value in zip(m, v, strict=True):

40 for scale, factor in d_r:

41 with domain_range_scale(scale):

42 np.testing.assert_allclose(

43 delta_E(Lab_1 * factor, Lab_2 * factor, method),

44 value,

45 atol=TOLERANCE_ABSOLUTE_TESTS,

46 )