3.6.17. qupulse.pulses.sequence_pulse_template¶
This module defines SequencePulseTemplate, a higher-order hierarchical pulse template that combines several other PulseTemplate objects for sequential execution.
Classes
|
A sequence of different PulseTemplates. |
- class SequencePulseTemplate(*subtemplates: PulseTemplate | Tuple[PulseTemplate] | Tuple[PulseTemplate, Dict] | Tuple[PulseTemplate, Dict, Dict] | Tuple[PulseTemplate, Dict, Dict, Dict], identifier: str | None = None, parameter_constraints: Iterable[Expr | str | ParameterConstraint] | None = None, measurements: List[Tuple[str, Expression | str | Real, Expression | str | Real]] | None = None, metadata: TemplateMetadata | dict = None, registry: MutableMapping[str, Serializable] | None = None)[source]¶
Bases:
PulseTemplate,ParameterConstrainer,MeasurementDefinerA sequence of different PulseTemplates.
SequencePulseTemplate allows grouping several PulseTemplates (subtemplates) into one larger sequence. When instantiating a pulse from a SequencePulseTemplate all pulses instantiated from the subtemplates are queued right after one another.
Furthermore, this class allows associating an identifier, measurements, and parameter constraints with this sequence. If none of the subtemplates evaluate to anything during instantiation, the associated measurements are dropped.
For more concise syntax, the subtemplate can be stated in the form of a “mapping tuple” that is passed to
MappingPulseTemplate.from_tuple(). This allows the mathematical mapping if pulse parameters and renaming of channels and measurement declarations.The only required arguments are the subtemplates. Besides creating
MappingPulseTemplates from tuples, the subtemplates are not modified and particularly nested sequences are not flattened in hierarchy. UseSequencePulseTemplate.concatenate()or the@operator if you want automatic flattening.You can specify
to_single_waveform == 'always'in the metadata to enforce translation into a single waveform.- Raises:
ValueError – if the subtemplates are defined on different channels.
- Parameters:
subtemplates – The subtemplates given as PulseTemplate or as a tuple compatible with
MappingPulseTemplate.from_tuple().identifier – A unique identifier for use in serialization.
parameter_constraints – A list of constraints checked on instantiation.
measurements – A list of measurement declarations associated with this sequence.
metadata – An optional metadata associated with this sequence.
registry – A PulseRegistryType or a subclass of PulseRegistryType.
- build_waveform(parameters: Dict[str, Real], channel_mapping: Dict[str | int, str | int]) SequenceWaveform[source]¶
- classmethod concatenate(*pulse_templates: PulseTemplate | Tuple[PulseTemplate] | Tuple[PulseTemplate, Dict] | Tuple[PulseTemplate, Dict, Dict] | Tuple[PulseTemplate, Dict, Dict, Dict], **kwargs) SequencePulseTemplate[source]¶
Sequences the given pulse templates by creating a SequencePulseTemplate. Pulse templates that are SequencePulseTemplates and do not carry additional information (identifier, measurements, parameter constraints) are not used directly but their sub templates are. :param *pulse_templates: Pulse templates to concatenate :param **kwargs: Forwarded to the __init__
Returns: Concatenated templates
- property defined_channels: Set[str | int]¶
Implements
PulseTemplate.defined_channels.
- classmethod deserialize(serializer: Serializer | None = None, **kwargs) SequencePulseTemplate[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: Expression¶
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 measurement_names: AbstractSet[str]¶
Implements
PulseTemplate.measurement_names.
- property parameter_names: Set[str]¶
Implements
PulseTemplate.parameter_names.
- property subtemplates: List[MappingPulseTemplate]¶