Skip to content

ParameterBag

Parameter flat key-value store for use with a container.

Allows storing and retrieving of parameters in the bag. Templated strings can be used to interpolate a string referencing parameters.

Functions

__init__()

Initialize an empty ParameterBag.

ParameterBag holds a flat key-value store of parameter values. __bag: A dictionary to store parameter values. __cache: A cache for interpolated values. __param_cache: A dictionary to keep track of which cache entries involve each parameter.

get(param)

Get the value of a parameter.

If the parameter is templated, interpolate it first by replacing placeholders with parameter values.

Parameters:

Name Type Description Default
param ParameterReference

The parameter to retrieve.

required

Returns:

Type Description
Any

The parameter's value.

get_all()

Get all parameters stored in the bag.

Returns:

Type Description
dict[str, Any]

A dictionary containing all parameter names and their values.

put(name, val)

Put a parameter value into the bag. This overwrites any previous values.

Parameters:

Name Type Description Default
name str

The name of the parameter.

required
val Any

The value of the parameter.

required

update(new_params)

Update the bag with new set of parameters.

Parameters from new_params will overwrite any existing parameters set with the same name.

Parameters:

Name Type Description Default
new_params dict[str, Any]

A dictionary of parameter names and their updated values.

required