create_component#
- create_component(component_class, params=None)[source]#
Helper function to create a component instance with parameters.
This function creates a callable object that will instantiate the component with the given parameters when called by the model.
- Parameters:
component_class (
type[TypeVar(T, bound=BaseComponent)]) – The component class to instantiate**kwargs – Parameters to pass to the component constructor
- Returns:
A function that creates the component instance when called by the model
- Return type:
Callable[[Any,Any],TypeVar(T, bound=BaseComponent)]
Examples
>>> model.components = [ ... create_component(MyComponent, params=MyComponentParams), ... AnotherComponent, ... ]