3.5.5. qupulse.program.values

Runtime variable value implementations.

Classes

DynamicLinearValue(base, factors)

This is a potential runtime-evaluable expression of the form

DynamicLinearValueStepped(base, factors, ...)

ResolutionDependentValue(bases, ...)

This is a potential runtime-evaluable expression of the form

class DynamicLinearValue(base: NumVal, factors: Mapping[str, NumVal])[source]

Bases: Generic[NumVal]

This is a potential runtime-evaluable expression of the form

C + C1*R1 + C2*R2 + … where R1, R2, … are potential runtime parameters.

The main use case is the expression of for loop-dependent variables where the Rs are loop indices. There the expressions can be calculated via simple increments.

This class tries to pass a number and a sympy.expr.Expr on best effort basis.

base: NumVal

The part of this expression which is not runtime parameter-dependent

factors: Mapping[str, NumVal]

A mapping of inner parameter names to the factor with which they contribute to the final value.

property free_symbols

This is required for the sympy.expr.Expr interface compliance. Since the keys of offsets are internal parameters we do not have free symbols.

Returns:

An empty tuple

replace(r, s)[source]

We mock sympy.Expr.replace here. This class does not support inner parameters so there is nothing to replace. Importantly, the keys of the offsets are no runtime variables!

Returns:

self

value(scope: Mapping[str, NumVal]) NumVal[source]

Numeric value of the expression with the given scope. :param scope: Scope in which the expression is evaluated.

Returns:

The numeric value.

class DynamicLinearValueStepped(base: NumVal, factors: Mapping[str, NumVal], step_nesting_level: int, rng: range, reverse: int | bool)[source]

Bases: DynamicLinearValue

reverse: int | bool
rng: range
step_nesting_level: int
class ResolutionDependentValue(bases: Tuple[NumVal, ...], multiplicities: Tuple[int, ...], offset: NumVal)[source]

Bases: Generic[NumVal]

This is a potential runtime-evaluable expression of the form

o + sum_i b_i*m_i

with (potential) float o, b_i and integers m_i. o and b_i are rounded(gridded) to a resolution given upon __call__.

The main use case is the correct rounding of increments used in command-based voltage scans on some hardware devices, where an imprecise numeric value is looped over m_i times and could, if not rounded, accumulate a proportional error leading to unintended drift in output voltages when jump-back commands afterwards do not account for the deviations. Rounding the value preemptively and supplying corrected values to jump-back commands prevents this.

bases: Tuple[NumVal, ...]
multiplicities: Tuple[int, ...]
offset: NumVal
with_resolution(resolution: NumVal | None) NumVal[source]

Get the numeric value rounding to the given resolution.

Parameters:

resolution – Resolution the bases and offset are rounded to. If none all values must be integers.

Returns:

The rounded numeric value.