3.7.16. qupulse.pulses.repetition_pulse_template

This module defines RepetitionPulseTemplate, a higher-order hierarchical pulse template that represents the n-times repetition of another PulseTemplate.

Classes

RepetitionPulseTemplate(body, repetition_count)

Repeats a PulseTemplate a constant number of times (possibly determined by a parameter value).

Exceptions

ParameterNotIntegerException(parameter_name, ...)

Indicates that the value of the parameter given as repetition count was not an integer.

exception qupulse.pulses.repetition_pulse_template.ParameterNotIntegerException(parameter_name: str, parameter_value: Any)[source]

Bases: Exception

Indicates that the value of the parameter given as repetition count was not an integer.

class qupulse.pulses.repetition_pulse_template.RepetitionPulseTemplate(body: qupulse.pulses.pulse_template.PulseTemplate, repetition_count: Union[int, str, qupulse.expressions.sympy.ExpressionScalar], identifier: Optional[str] = None, *args, parameter_constraints: Optional[List] = 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.loop_pulse_template.LoopPulseTemplate, qupulse.pulses.parameters.ParameterConstrainer, qupulse.pulses.measurement.MeasurementDefiner

Repeats a PulseTemplate a constant number of times (possibly determined by a parameter value).

RepetitionPulseTemplate simply repeats the given body PulseTemplate with the same parameter set for the specified number of times. It does not provide a loop index to the subtemplate. If you need to loop over an integer range and provide an index to the repeated template (at the cost of sequencing performance), use ForLoopPulseTemplate.

Create a new RepetitionPulseTemplate instance.

Parameters
  • body (PulseTemplate) – The PulseTemplate which will be repeated.

  • repetition_count (int or ParameterDeclaration) – The number of repetitions either as a constant integer value or as a parameter declaration.

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

__init__(body: qupulse.pulses.pulse_template.PulseTemplate, repetition_count: Union[int, str, qupulse.expressions.sympy.ExpressionScalar], identifier: Optional[str] = None, *args, parameter_constraints: Optional[List] = 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 RepetitionPulseTemplate instance.

Parameters
  • body (PulseTemplate) – The PulseTemplate which will be repeated.

  • repetition_count (int or ParameterDeclaration) – The number of repetitions either as a constant integer value or as a parameter declaration.

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

classmethod deserialize(serializer: Optional[qupulse.serialization.Serializer] = None, **kwargs) qupulse.pulses.repetition_pulse_template.RepetitionPulseTemplate[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_repetition_count_value(parameters: Mapping[str, numbers.Real]) int[source]
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: AbstractSet[str]

Implements parameter_names.

property repetition_count: qupulse.expressions.sympy.ExpressionScalar

The amount of repetitions. Either a constant integer or a ParameterDeclaration object.

with_repetition(repetition_count: Union[int, str, qupulse.expressions.sympy.ExpressionScalar]) qupulse.pulses.pulse_template.PulseTemplate[source]

Repeat this pulse template repetition_count times via a RepetitionPulseTemplate.

Examples

>>> from qupulse.pulses import FunctionPT
... fpt = FunctionPT('sin(0.1 * t)', duration_expression=10)
... repeated = fpt.with_repetition('n_periods')
Parameters

repetition_count – Amount of times this pulse template is repeated in the return value.

Returns

A newly created pulse template.