3.6.6. qupulse.pulses.loop_pulse_template¶
This module defines LoopPulseTemplate, a higher-order hierarchical pulse template that loops its body PulseTemplate.
Classes
|
This pulse template allows looping through a parametrized integer range and provides the loop index as a parameter to the body. |
|
Base class for loop based pulse templates. |
Exceptions
|
- class ForLoopPulseTemplate(body: PulseTemplate, loop_index: str, loop_range: int | range | str | Tuple[Any, Any] | Tuple[Any, Any, Any] | ParametrizedRange, identifier: str | None = None, *, measurements: Sequence[Tuple[str, Expression | str | Real, Expression | str | Real]] | None = None, parameter_constraints: Sequence | None = None, metadata: TemplateMetadata | dict = None, registry: MutableMapping[str, Serializable] | None = None)[source]¶
Bases:
LoopPulseTemplate,MeasurementDefiner,ParameterConstrainerThis pulse template allows looping through a 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.Besides direct creation, you can construct this pulse template with the
PulseTemplate.with_iteration()helper method.You can associate an identifier, measurements and parameter constraints with this pulse template. If the pulse template does not result in any output (for example, because the range evaluates to an empty range or the body is empty at runtime) the measurements are dropped as well.
- Parameters:
body – The loop body. It is expected to have
loop_indexas a parameter.loop_index – Loop index of the loop.
loop_range – Range to loop through. Used to construct a
ParametrizedRange.identifier – Used for serialization and the pulse registry
measurements – Measurements passed to
MeasurementDefinersuperclassparameter_constraints – Constraints passed to
ParameterConstrainersuperclassregistry – The new pulse is registered there after initialization.
metadata – Used to initialize
PulseTemplate.metadata
- Raises:
.LoopIndexNotUsedException –
- build_waveform(parameter_scope: Scope) SequenceWaveform[source]¶
- classmethod deserialize(serializer: Serializer | None = None, **kwargs) 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: ExpressionScalar¶
Implements
PulseTemplate.duration().
- property final_values: Dict[str | int, ExpressionScalar]¶
Values of defined channels at t == self.duration
- get_serialization_data(serializer: Serializer | None = 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[str | int, ExpressionScalar]¶
Values of defined channels at t == 0
- property integral: Dict[str | int, ExpressionScalar]¶
Implements
PulseTemplate.integral.
- property loop_range: ParametrizedRange¶
- property measurement_names: Set[str]¶
Implements
PulseTemplate.measurement_names.
- property parameter_names: Set[str]¶
Implements
PulseTemplate.parameter_names.
- exception LoopIndexNotUsedException(loop_index: str, body_parameter_names: Set[str])[source]¶
Bases:
Exception
- class LoopPulseTemplate(body: PulseTemplate, identifier: str | None, metadata: TemplateMetadata | dict = None)[source]¶
Bases:
PulseTemplateBase 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: PulseTemplate¶
- property defined_channels: Set[str | int]¶
Implements
PulseTemplate.defined_channels.
- property measurement_names: Set[str]¶
Implements
PulseTemplate.measurement_names.