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

12 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-16 22:49 +1300

1""" 

2Linear Colour Component Transfer Function 

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

4 

5Define the linear encoding / decoding colour component transfer function 

6related objects. 

7 

8- :func:`colour.linear_function` 

9""" 

10 

11from __future__ import annotations 

12 

13import typing 

14 

15if typing.TYPE_CHECKING: 

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

17 

18from 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 

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

34@typing.overload 

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

36@typing.overload 

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

38def 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)