colour.get_domain_range_scale_metadata#

colour.get_domain_range_scale_metadata(function: Callable) dict[str, Any][source]#

Extract domain-range scale metadata from function type hints.

Extracts scale factors from PEP 593 Annotated type hints on function parameters and return values. This metadata indicates which scale factors to use when converting between ‘Reference’ and ‘1’ modes.

Parameters:

function (Callable) – Function to extract metadata from.

Returns:

Dictionary with keys:

  • domain: Dict mapping parameter names to their scale factors

  • range: Scale factor for return value (int, tuple, or None)

Return type:

dict

Examples

>>> from colour.hints import Annotated, ArrayLike, NDArrayFloat
>>> def example_function(
...     XYZ: Domain1,
...     illuminant: ArrayLike = None,
... ) -> Range100:
...     pass
>>> metadata = get_domain_range_scale_metadata(example_function)
>>> metadata["domain"]
{'XYZ': 1}
>>> metadata["range"]
100