Coverage for models/rgb/transfer_functions/linear.py: 8%

1"""

2 Linear Colour Component Transfer Function

3=========================================

4

5 Define the linear encoding / decoding colour component transfer function

6 related objects.

7

8- :func:`colour.linear_function`

9"""

10

11 from __future__ import annotations

12

13 import typing

14

15 if typing.TYPE_CHECKING:

16 from colour.hints import ArrayLike, DTypeFloat, NDArray, NDArrayFloat

17

18 from colour.utilities import as_float

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 "linear_function",

29]

30

31

32@typing.overload

33 def linear_function(a: float | DTypeFloat) -> DTypeFloat: ...

34@typing.overload

35 def linear_function(a: NDArray) -> NDArrayFloat: ...

36@typing.overload

37 def linear_function(a: ArrayLike) -> DTypeFloat | NDArrayFloat: ...

38 def linear_function(a: ArrayLike) -> DTypeFloat | NDArrayFloat:

39 """

40 Perform pass-through linear encoding/decoding transformation.

41

42 Implement an identity transformation where the output equals the input,

43 commonly used as a reference or default encoding/decoding function in

44 colour science workflows.

45

46 Parameters

47 ----------

48 a

49 Array to encode/decode.

50

51 Returns

52 -------

53 :class:`numpy.ndarray`

54 Encoded/decoded array, identical to input.

55

56 Examples

57 --------

58 >>> linear_function(0.18) # doctest: +ELLIPSIS

59 0.1799999...

60 """

61

62 return as_float(a)