3.7.6. qupulse.pulses.loop_pulse_template¶
This module defines LoopPulseTemplate, a higher-order hierarchical pulse template that loops another PulseTemplate based on a condition.
Classes
|
This pulse template allows looping through an parametrized integer range and provides the loop index as a parameter to the body. |
|
Base class for loop based pulse templates. |
Exceptions
|
- class qupulse.pulses.loop_pulse_template.ForLoopPulseTemplate(body: qupulse.pulses.pulse_template.PulseTemplate, loop_index: str, loop_range: Union[int, range, str, Tuple[Any, Any], Tuple[Any, Any, Any], qupulse.pulses.range.ParametrizedRange], identifier: Optional[str] = None, *, measurements: Optional[Sequence[Tuple[str, Union[qupulse.expressions.sympy.Expression, str, numbers.Real], Union[qupulse.expressions.sympy.Expression, str, numbers.Real]]]] = None, parameter_constraints: Optional[Sequence] = None, registry: Optional[MutableMapping[str, Serializable]] = None)[source]¶
Bases:
qupulse.pulses.loop_pulse_template.LoopPulseTemplate
,qupulse.pulses.measurement.MeasurementDefiner
,qupulse.pulses.parameters.ParameterConstrainer
This pulse template allows looping through an parametrized integer range and provides the loop index as a parameter to the body. If you do not need the index in the pulse template, consider using
RepetitionPulseTemplate
- Parameters
body – The loop body. It is expected to have loop_index as an parameter
loop_index – Loop index of the for loop
loop_range – Range to loop through
identifier – Used for serialization
- __init__(body: qupulse.pulses.pulse_template.PulseTemplate, loop_index: str, loop_range: Union[int, range, str, Tuple[Any, Any], Tuple[Any, Any, Any], qupulse.pulses.range.ParametrizedRange], identifier: Optional[str] = None, *, measurements: Optional[Sequence[Tuple[str, Union[qupulse.expressions.sympy.Expression, str, numbers.Real], Union[qupulse.expressions.sympy.Expression, str, numbers.Real]]]] = None, parameter_constraints: Optional[Sequence] = None, registry: Optional[MutableMapping[str, Serializable]] = None) None [source]¶
- Parameters
body – The loop body. It is expected to have loop_index as an parameter
loop_index – Loop index of the for loop
loop_range – Range to loop through
identifier – Used for serialization
- build_waveform(parameter_scope: qupulse.parameter_scope.Scope) qupulse.program.waveforms.SequenceWaveform [source]¶
- classmethod deserialize(serializer: Optional[qupulse.serialization.Serializer] = None, **kwargs) qupulse.pulses.loop_pulse_template.ForLoopPulseTemplate [source]¶
Reconstructs the Serializable object from a dictionary.
Implementation hint: For greater clarity, implementations of this method should be precise in their return value, i.e., give their exact class name, and also replace the kwargs argument by a list of arguments required, i.e., those returned by get_serialization_data. Using old serialization routines, if this Serializable contains complex objects which are itself of type Serializable, their dictionary representations MUST be converted into objects using serializers deserialize() method. This is DEPRECATED behavior. Using the new routines, a serializable is only responsible to decode it’s own dictionary, not those of nested objects (i.e., all incoming arguments are already processed by the serialization routines). For the transition time where both variants are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. For the new routines, just call this base class function. After the transition period, subclasses likely need not implement deserialize separately anymore at all.
- Parameters
serializer – DEPRECATED (May 2018). A serializer instance used when deserializing subelements.
**kwargs – All relevant properties of the object as keyword arguments. For every (key,value) pair returned by get_serialization_data, the same pair is given as keyword argument as input to this method.
- property duration: qupulse.expressions.sympy.ExpressionScalar¶
Implements
duration()
.
- property final_values: Dict[Union[str, int], qupulse.expressions.sympy.ExpressionScalar]¶
Values of defined channels at t == self.duration
- get_serialization_data(serializer: Optional[qupulse.serialization.Serializer] = None) Dict[str, Any] [source]¶
Returns all data relevant for serialization as a dictionary containing only base types.
Implementation hint: In the old serialization routines, if the Serializable contains complex objects which are itself Serializables, a serialized representation for these MUST be obtained by calling the dictify() method of serializer. The reason is that serializer may decide to either return a dictionary to embed or only a reference to the Serializable subelement. This is DEPRECATED behavior as of May 2018. In the new routines, this will happen automatically and every Serializable is only responsible for returning it’s own data and leave nested Serializables in object form.
For the transition time where both implementations are available, implementations of this method should support the old and new routines, using the presence of the serializer argument to differentiate between both. Don’t make use of the implementation in this base class when implementing this method for the old routines.
- Parameters
serializer (Serializer) – DEPRECATED (May 2018).A Serializer instance used to serialize complex subelements of this Serializable.
- Returns
- A dictionary of Python base types (strings, integers, lists/tuples containing these,
etc..) which fully represent the relevant properties of this Serializable for storing and later reconstruction as a Python object.
- property initial_values: Dict[Union[str, int], qupulse.expressions.sympy.ExpressionScalar]¶
Values of defined channels at t == 0
- property integral: Dict[Union[str, int], qupulse.expressions.sympy.ExpressionScalar]¶
Implements
integral
.
- property loop_range: qupulse.pulses.range.ParametrizedRange¶
- property measurement_names: Set[str]¶
Implements
measurement_names
.
- property parameter_names: Set[str]¶
Implements
parameter_names
.
- exception qupulse.pulses.loop_pulse_template.LoopIndexNotUsedException(loop_index: str, body_parameter_names: Set[str])[source]¶
Bases:
Exception
- class qupulse.pulses.loop_pulse_template.LoopPulseTemplate(body: qupulse.pulses.pulse_template.PulseTemplate, identifier: Optional[str])[source]¶
Bases:
qupulse.pulses.pulse_template.PulseTemplate
Base class for loop based pulse templates. This class is still abstract and cannot be instantiated.
Initializes a Serializable.
- Parameters
identifier – An optional, non-empty identifier for this Serializable. If set, this Serializable will always be stored as a separate data item and never be embedded.
- Raises
ValueError – If identifier is the empty string
- property body: qupulse.pulses.pulse_template.PulseTemplate¶
- property defined_channels: Set[Union[str, int]]¶
Implements
defined_channels
.
- property measurement_names: Set[str]¶
Implements
measurement_names
.