colour.utilities.filter_kwargs

colour.utilities.filter_kwargs(function, **kwargs)[source]

Filters keyword arguments incompatible with the given function signature.

Parameters

function (callable) – Callable to filter the incompatible keyword arguments.

Other Parameters

**kwargs (dict, optional) – Keywords arguments.

Returns

Filtered keyword arguments.

Return type

dict

Examples

>>> def fn_a(a):
...     return a
>>> def fn_b(a, b=0):
...     return a, b
>>> def fn_c(a, b=0, c=0):
...     return a, b, c
>>> fn_a(1, **filter_kwargs(fn_a, b=2, c=3))
1
>>> fn_b(1, **filter_kwargs(fn_b, b=2, c=3))
(1, 2)
>>> fn_c(1, **filter_kwargs(fn_c, b=2, c=3))
(1, 2, 3)