3.7.4. qupulse.pulses.function_pulse_template

This module defines the FunctionPulseTemplate, one of the elementary pulse templates and its waveform representation.

Classes:
  • FunctionPulseTemplate: Defines a pulse via a mathematical function.

Classes

FunctionPulseTemplate(expression, ...[, ...])

Defines a pulse via a time-domain expression.

class qupulse.pulses.function_pulse_template.FunctionPulseTemplate(expression: Union[str, qupulse.expressions.sympy.ExpressionScalar], duration_expression: Union[str, qupulse.expressions.sympy.ExpressionScalar], channel: Union[str, int] = 'default', identifier: Optional[str] = None, *, measurements: Optional[List[Tuple[str, Union[qupulse.expressions.sympy.Expression, str, numbers.Real], Union[qupulse.expressions.sympy.Expression, str, numbers.Real]]]] = None, parameter_constraints: Optional[List[Union[str, qupulse.pulses.parameters.ParameterConstraint]]] = None, registry: Optional[MutableMapping[str, Serializable]] = None)[source]

Bases: qupulse.pulses.pulse_template.AtomicPulseTemplate, qupulse.pulses.parameters.ParameterConstrainer

Defines a pulse via a time-domain expression.

FunctionPulseTemplate stores the expression and its external parameters. The user must provide two things: one expression that calculates the length of the pulse from the external parameters and the time-domain pulse shape itself as a expression. The required external parameters are derived from the free variables in the expressions themselves. Like other PulseTemplates the FunctionPulseTemplate can be declared to be a measurement pulse.

The independent variable for the time domain in the expression is expected to be called ‘t’.

Creates a new FunctionPulseTemplate object.

Parameters
  • expression – The function represented by this FunctionPulseTemplate as a mathematical expression where ‘t’ denotes the time variable and other variables will be parameters of the pulse.

  • duration_expression – A mathematical expression which reliably computes the duration of an instantiation of this FunctionPulseTemplate from provided parameter values.

  • channel – The channel this pulse template is defined on.

  • identifier – A unique identifier for use in serialization.

  • measurements – A list of measurement declarations forwarded to the MeasurementDefiner superclass

  • parameter_constraints – A list of parameter constraints forwarded to the ParameterConstrainer superclass

__init__(expression: Union[str, qupulse.expressions.sympy.ExpressionScalar], duration_expression: Union[str, qupulse.expressions.sympy.ExpressionScalar], channel: Union[str, int] = 'default', identifier: Optional[str] = None, *, measurements: Optional[List[Tuple[str, Union[qupulse.expressions.sympy.Expression, str, numbers.Real], Union[qupulse.expressions.sympy.Expression, str, numbers.Real]]]] = None, parameter_constraints: Optional[List[Union[str, qupulse.pulses.parameters.ParameterConstraint]]] = None, registry: Optional[MutableMapping[str, Serializable]] = None) None[source]

Creates a new FunctionPulseTemplate object.

Parameters
  • expression – The function represented by this FunctionPulseTemplate as a mathematical expression where ‘t’ denotes the time variable and other variables will be parameters of the pulse.

  • duration_expression – A mathematical expression which reliably computes the duration of an instantiation of this FunctionPulseTemplate from provided parameter values.

  • channel – The channel this pulse template is defined on.

  • identifier – A unique identifier for use in serialization.

  • measurements – A list of measurement declarations forwarded to the MeasurementDefiner superclass

  • parameter_constraints – A list of parameter constraints forwarded to the ParameterConstrainer superclass

build_waveform(parameters: Dict[str, numbers.Real], channel_mapping: Dict[Union[str, int], Optional[Union[str, int]]]) Optional[qupulse.program.waveforms.FunctionWaveform][source]

Implements build_waveform().

property defined_channels: Set[Union[str, int]]

Implements defined_channels.

classmethod deserialize(serializer: Optional[qupulse.serialization.Serializer] = None, **kwargs) qupulse.pulses.function_pulse_template.FunctionPulseTemplate[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 expression: qupulse.expressions.sympy.ExpressionScalar
property final_values: Dict[Union[str, int], qupulse.expressions.sympy.ExpressionScalar]

Values of defined channels at t == self.duration

property function_parameters: Set[str]
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 parameter_names: Set[str]

Implements parameter_names.