Coverage for colorimetry/tests/test_correction.py: 100%

1"""Define the unit tests for the :mod:`colour.colorimetry.correction` module."""

2

3 from __future__ import annotations

4

5 import numpy as np

6

7 from colour.colorimetry import SpectralDistribution, bandpass_correction_Stearns1988

8 from colour.constants import TOLERANCE_ABSOLUTE_TESTS

9

10 __author__ = "Colour Developers"

11 __copyright__ = "Copyright 2013 Colour Developers"

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

13 __maintainer__ = "Colour Developers"

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

15 __status__ = "Production"

16

17 __all__ = [

18 "DATA_NON_BANDPASS_CORRECTED",

19 "DATA_BANDPASS_CORRECTED",

20 "TestBandpassCorrectionStearns1988",

21]

22

23 DATA_NON_BANDPASS_CORRECTED: tuple = (

24 9.3700,

25 12.3200,

26 12.4600,

27 9.5100,

28 5.9200,

29 4.3300,

30 4.2900,

31 3.8800,

32 4.5100,

33 10.9200,

34 27.5000,

35 49.6700,

36 69.5900,

37 81.7300,

38 88.1900,

39 86.0500,

40)

41

42 DATA_BANDPASS_CORRECTED: tuple = (

43 9.12515000,

44 12.57355255,

45 12.69542514,

46 9.54357971,

47 5.75121288,

48 4.21535933,

49 4.33022518,

50 3.79034131,

51 4.03770167,

52 10.11509076,

53 27.10283747,

54 49.88971449,

55 70.21750370,

56 82.14935719,

57 88.88373581,

58 85.87238000,

59)

60

61

62 class TestBandpassCorrectionStearns1988:

63 """

64 Define :func:`colour.colorimetry.correction.\

65 bandpass_correction_Stearns1988` definition unit tests methods.

66 """

67

68 def test_bandpass_correction_Stearns1988(self) -> None:

69 """

70 Test :func:`colour.colorimetry.correction.\

71 bandpass_correction_Stearns1988` definition.

72 """

73

74 sd = SpectralDistribution(

75 dict(

76 zip(

77 range(len(DATA_NON_BANDPASS_CORRECTED)),

78 DATA_NON_BANDPASS_CORRECTED,

79 strict=True,

80 )

81 )

82 )

83

84 np.testing.assert_allclose(

85 bandpass_correction_Stearns1988(sd).values,

86 DATA_BANDPASS_CORRECTED,

87 atol=TOLERANCE_ABSOLUTE_TESTS,

88 )