3.7.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

SequencePulseTemplate(*subtemplates[, ...])

A sequence of different PulseTemplates.

class qupulse.pulses.sequence_pulse_template.SequencePulseTemplate(*subtemplates: Union[qupulse.pulses.pulse_template.PulseTemplate, Tuple[PulseTemplate], Tuple[PulseTemplate, Dict], Tuple[PulseTemplate, Dict, Dict], Tuple[PulseTemplate, Dict, Dict, Dict]], identifier: Optional[str] = None, parameter_constraints: Optional[Iterable[Union[sympy.core.expr.Expr, str, qupulse.pulses.parameters.ParameterConstraint]]] = None, measurements: Optional[List[Tuple[str, Union[qupulse.expressions.sympy.Expression, str, numbers.Real], Union[qupulse.expressions.sympy.Expression, str, numbers.Real]]]] = None, registry: Optional[MutableMapping[str, Serializable]] = None)[source]

Bases: qupulse.pulses.pulse_template.PulseTemplate, qupulse.pulses.parameters.ParameterConstrainer, qupulse.pulses.measurement.MeasurementDefiner

A sequence of different PulseTemplates.

SequencePulseTemplate allows to group several PulseTemplates (subtemplates) into one larger sequence, i.e., when instantiating a pulse from a SequencePulseTemplate all pulses instantiated from the subtemplates are queued for execution right after one another. SequencePulseTemplate requires to specify a mapping of parameter declarations from its subtemplates to its own, enabling renaming and mathematical transformation of parameters.

Create a new SequencePulseTemplate instance.

Requires a (correctly ordered) list of subtemplates in the form (PulseTemplate, Dict(str -> str)) where the dictionary is a mapping between the external parameters exposed by this SequencePulseTemplate to the parameters declared by the subtemplates, specifying how the latter are derived from the former, i.e., the mapping is subtemplate_parameter_name -> mapping_expression (as str) where the free variables in the mapping_expression are parameters declared by this SequencePulseTemplate.

The following requirements must be satisfied:
  • for each parameter declared by a subtemplate, a mapping expression must be provided

  • each free variable in a mapping expression must be declared as an external parameter

    of this SequencePulseTemplate

Parameters
  • subtemplates (List(Subtemplate)) – The list of subtemplates of this SequencePulseTemplate as tuples of the form (PulseTemplate, Dict(str -> str)).

  • identifier (str) – A unique identifier for use in serialization. (optional)

__init__(*subtemplates: Union[qupulse.pulses.pulse_template.PulseTemplate, Tuple[PulseTemplate], Tuple[PulseTemplate, Dict], Tuple[PulseTemplate, Dict, Dict], Tuple[PulseTemplate, Dict, Dict, Dict]], identifier: Optional[str] = None, parameter_constraints: Optional[Iterable[Union[sympy.core.expr.Expr, str, qupulse.pulses.parameters.ParameterConstraint]]] = None, measurements: Optional[List[Tuple[str, Union[qupulse.expressions.sympy.Expression, str, numbers.Real], Union[qupulse.expressions.sympy.Expression, str, numbers.Real]]]] = None, registry: Optional[MutableMapping[str, Serializable]] = None) None[source]

Create a new SequencePulseTemplate instance.

Requires a (correctly ordered) list of subtemplates in the form (PulseTemplate, Dict(str -> str)) where the dictionary is a mapping between the external parameters exposed by this SequencePulseTemplate to the parameters declared by the subtemplates, specifying how the latter are derived from the former, i.e., the mapping is subtemplate_parameter_name -> mapping_expression (as str) where the free variables in the mapping_expression are parameters declared by this SequencePulseTemplate.

The following requirements must be satisfied:
  • for each parameter declared by a subtemplate, a mapping expression must be provided

  • each free variable in a mapping expression must be declared as an external parameter

    of this SequencePulseTemplate

Parameters
  • subtemplates (List(Subtemplate)) – The list of subtemplates of this SequencePulseTemplate as tuples of the form (PulseTemplate, Dict(str -> str)).

  • identifier (str) – A unique identifier for use in serialization. (optional)

build_waveform(parameters: Dict[str, numbers.Real], channel_mapping: Dict[Union[str, int], Union[str, int]]) qupulse.program.waveforms.SequenceWaveform[source]
classmethod concatenate(*pulse_templates: Union[qupulse.pulses.pulse_template.PulseTemplate, Tuple[qupulse.pulses.pulse_template.PulseTemplate], Tuple[qupulse.pulses.pulse_template.PulseTemplate, Dict], Tuple[qupulse.pulses.pulse_template.PulseTemplate, Dict, Dict], Tuple[qupulse.pulses.pulse_template.PulseTemplate, Dict, Dict, Dict]], **kwargs) qupulse.pulses.sequence_pulse_template.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[Union[str, int]]

Implements defined_channels.

classmethod deserialize(serializer: Optional[qupulse.serialization.Serializer] = None, **kwargs) qupulse.pulses.sequence_pulse_template.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: qupulse.expressions.sympy.Expression

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 measurement_names: AbstractSet[str]

Implements measurement_names.

property parameter_names: Set[str]

Implements parameter_names.

property subtemplates: List[qupulse.pulses.mapping_pulse_template.MappingPulseTemplate]