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.

__init__(parameters: Sequence[Parameter[T]], default: T | None = None) None[source]#

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

changed

Returns whether the parameter was explicitly set

is_default

Returns whether the default value is set

is_set

Indicates whether the parameter has been set to a non-None value.

parents

Provides the original parent nodes of all contained parameters.

path

Provides a unique path to the interface.

serialized

Provides a serialized summary of the parameter

value

Provides the value of the parameter.

name

parent

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

property changed: bool#

Returns whether the parameter was explicitly set

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:

bool

property is_default: bool#

Returns whether the default value is set

property is_set: bool#

Indicates whether the parameter has been set to a non-None value.

property parents: list[Component]#

Provides the original parent nodes of all contained parameters.

property path: tuple[str, ...]#

Provides a unique path to the interface.

property serialized: dict[str, Any]#

Provides a serialized summary of the parameter

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.