CADETProcess.dataStructure.parameter.Callable

Contents

CADETProcess.dataStructure.parameter.Callable#

class CADETProcess.dataStructure.parameter.Callable(*args, default=None, is_optional=False, unit=None, description=None, **kwargs)[source]#

Parameter descriptor constrained to callable objects.

Designed to ensure a given parameter is callable. This is distinct from using a type constraint since built-in functions (e.g., those implemented in C) won’t be captured by types.FunctionTypes.

See also

Parameter
Typed

Examples

Here’s how you might use the Callable class:

>>> class MyModel:
...     func = Callable()
...
>>> model = MyModel()
>>> model.func = print  # This is fine as print is callable
>>> model.func = "not_callable"  # This will raise a TypeError
Attributes:
default

Any: Get or set the default value of the parameter.

Methods

get_default_value(instance)

Return default values if necessary.