3.3. qupulse.parameter_scope

Contains various implementations of the parameter lookup interface Scope

Classes

DictScope(values[, volatile])

JointScope(lookup)

MappedScope(scope, mapping)

Scope()

Abstract parameter lookup. Scopes are immutable. Internally it holds all dependencies of parameters and keeps

Exceptions

NonVolatileChange

Raised if a non volatile parameter is updated

ParameterNotProvidedException(parameter_name)

Indicates that a required parameter value was not provided.

class DictScope(values: Mapping[str, Number], volatile: AbstractSet[str] = frozenset({}))[source]

Bases: Scope

change_constants(new_constants: Mapping[str, Number]) Scope[source]

Change values of constants. Constants not present in the scope are ignored.

Parameters:

new_constants

Warning

NonVolatileChange: if a parameter that is not in get_volatile_parameters is updated

Returns:

New scope instance

classmethod from_kwargs(*, volatile: AbstractSet[str] = frozenset({}), **kwargs: Number) DictScope[source]
classmethod from_mapping(mapping: Mapping[str, Number], volatile: AbstractSet[str] = frozenset({})) DictScope[source]
get_parameter(parameter_name) Number[source]
Parameters:

parameter_name

Raises:

ParameterNotProvidedException if the parameter is not provided by this scope

Returns:

Parameter value

get_volatile_parameters() Mapping[str, Expression][source]
Returns:

A mapping where the keys are the volatile parameters and the

items
keys
values
class JointScope(lookup: Mapping[str, Scope])[source]

Bases: Scope

change_constants(new_constants: Mapping[str, Number]) JointScope[source]

Change values of constants. Constants not present in the scope are ignored.

Parameters:

new_constants

Warning

NonVolatileChange: if a parameter that is not in get_volatile_parameters is updated

Returns:

New scope instance

get_parameter(parameter_name: str) Number[source]
Parameters:

parameter_name

Raises:

ParameterNotProvidedException if the parameter is not provided by this scope

Returns:

Parameter value

get_volatile_parameters() Mapping[str, Expression][source]
Returns:

A mapping where the keys are the volatile parameters and the

class MappedScope(scope: Scope, mapping: Mapping[str, Expression])[source]

Bases: Scope

as_dict() Mapping[str, Number][source]
change_constants(new_constants: Mapping[str, Number]) MappedScope[source]

Change values of constants. Constants not present in the scope are ignored.

Parameters:

new_constants

Warning

NonVolatileChange: if a parameter that is not in get_volatile_parameters is updated

Returns:

New scope instance

get_parameter(parameter_name: str) Number[source]
Parameters:

parameter_name

Raises:

ParameterNotProvidedException if the parameter is not provided by this scope

Returns:

Parameter value

get_volatile_parameters() Mapping[str, Expression][source]
Returns:

A mapping where the keys are the volatile parameters and the

items() a set-like object providing a view on D's items[source]
keys() a set-like object providing a view on D's keys[source]
values() an object providing a view on D's values[source]
exception NonVolatileChange[source]

Bases: RuntimeWarning

Raised if a non volatile parameter is updated

exception ParameterNotProvidedException(parameter_name: str)[source]

Bases: KeyError

Indicates that a required parameter value was not provided.

property parameter_name
class Scope[source]

Bases: Mapping[str, Number]

Abstract parameter lookup. Scopes are immutable. Internally it holds all dependencies of parameters and keeps

track which had been marked as volatile. This allows creating a new scope with different volatile dependencies.

Parameter: A key, value pair in this Mapping Constant: A Volatile constant:

Equality: Scopes may not be equal even if type and abstract properties are equal. If you need semantic equality use Scope.as_dict()

as_dict() Mapping[str, Number][source]
abstractmethod change_constants(new_constants: Mapping[str, Number]) Scope[source]

Change values of constants. Constants not present in the scope are ignored.

Parameters:

new_constants

Warning

NonVolatileChange: if a parameter that is not in get_volatile_parameters is updated

Returns:

New scope instance

abstractmethod get_parameter(parameter_name: str) Number[source]
Parameters:

parameter_name

Raises:

ParameterNotProvidedException if the parameter is not provided by this scope

Returns:

Parameter value

abstractmethod get_volatile_parameters() Mapping[str, Expression][source]
Returns:

A mapping where the keys are the volatile parameters and the

overwrite(to_overwrite: Mapping[str, Number]) Scope[source]