MultiParameter#
- class maize.core.interface.MultiParameter(*args: Any, **kwargs: Any)[source]#
Bases:
Parameter
[T
]Container for multiple parameters. Allows setting multiple low-level parameters with a single high-level one.
When constructing subgraphs, one will often want to map a single parameter to multiple component nodes. This is where MultiParameter is useful, as it will automatically set those component parameters. If you wish to perform some more elaborate processing instead, subclass MultiParameter and overwrite the MultiParameter.set method.
Do not use this class directly, instead make use of the
maize.core.graph.Graph.combine_parameters()
method.- Parameters:
default – Default value for the parameter
parameters – Sequence of Parameter instances that will be updated with a call to set
- name#
Name of the parameter
- parent#
Parent component
See also
graph.Graph.combine_parameters
Uses MultiParameter in the background to combine multiple parameters from separate nodes into a single parameter for a subgraph.
Methods
__init__
(parameters[, default])as_dict
()Provide a dictionary representation of the parameter mapping.
build
(name, parent)Instantiate an interface from the description.
check
(value)Checks if a value is valid using type annotations.
set
(value)Sets all contained parameters to the value.
Attributes
Returns whether the parameter was explicitly set
Returns whether the default value is set
Indicates whether the parameter has been set to a non-
None
value.Provides the original parent nodes of all contained parameters.
Provides a unique path to the interface.
Provides a serialized summary of the parameter
Provides the value of the parameter.
datatype
doc
- as_dict() dict[str, str | T | list[dict[str, NestedDict[T, U] | str]] | None] [source]#
Provide a dictionary representation of the parameter mapping.
- Returns:
Dictionary representation of the MultiParameter
- Return type:
ParameterMappingType[T]
- build(name: str, parent: Component) _TInter [source]#
Instantiate an interface from the description.
- Parameters:
name – Name of the interface, will typically be the attribute name of the parent object
parent – Parent component instance
- Returns:
Copy of the current instance, with references to the name and the parent
- Return type:
_TInter
- check(value: T) bool #
Checks if a value is valid using type annotations.
- Parameters:
value – Value to typecheck
- Returns:
True
if the value is valid,False
otherwise- Return type:
- set(value: T) None [source]#
Sets all contained parameters to the value.
- Parameters:
value – The value to be set for all contained parameters
- property value: T#
Provides the value of the parameter.