3.6.5. qupulse.pulses.loop_pulse_template

This module defines LoopPulseTemplate, a higher-order hierarchical pulse template that loops another PulseTemplate based on a condition.

class qupulse.pulses.loop_pulse_template.ForLoopPulseTemplate(body, loop_index, loop_range, identifier=None, *, measurements=None, parameter_constraints=None, registry=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
__init__(body, loop_index, loop_range, identifier=None, *, measurements=None, parameter_constraints=None, registry=None)[source]
Parameters
Return type

None

build_waveform(parameter_scope)[source]
Return type

SequenceWaveform

classmethod deserialize(serializer=None, **kwargs)[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 (Optional[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.

Return type

ForLoopPulseTemplate

duration

Implements duration().

get_serialization_data(serializer=None)[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.

Return type

Dict[str, Any]

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 integral

Implements integral.

Return type

Dict[Union[str, int], ExpressionScalar]

property loop_index
Return type

str

property loop_range
Return type

ParametrizedRange

property measurement_names

Implements measurement_names.

Return type

Set[str]

property parameter_names

Implements parameter_names.

Return type

Set[str]

class qupulse.pulses.loop_pulse_template.LoopPulseTemplate(body, identifier)[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 (Optional[str]) – 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
Return type

PulseTemplate

property defined_channels

Implements defined_channels.

Return type

Set[Union[str, int]]

property measurement_names

Implements measurement_names.

Return type

Set[str]

exception qupulse.pulses.loop_pulse_template.LoopIndexNotUsedException(loop_index, body_parameter_names)[source]

Bases: Exception