3.7.2. qupulse.pulses.arithmetic_pulse_template

Functions

_apply_operation_to_channel_dict(lhs, rhs, ...)

_is_time_dependent(scalar)

try_operation(lhs, op, rhs, **kwargs)

param lhs

Left hand side operand

Classes

ArithmeticAtomicPulseTemplate(lhs, ...[, ...])

Apply an operation (+ or -) channel wise to two atomic pulse templates.

ArithmeticPulseTemplate(lhs, ...[, ...])

Implements the arithmetics between an aribrary pulse template and scalar values.

Exceptions

ImplicitAtomicityInArithmeticPT

Signals that an ArithmeticAtomicPulseTemplate has operands that are non-atomic but will be interpreted as atomic.

UnequalDurationWarningInArithmeticPT

Signals that an ArithmeticAtomicPulseTemplate was constructed from operands with unequal duration.

class qupulse.pulses.arithmetic_pulse_template.ArithmeticAtomicPulseTemplate(lhs: qupulse.pulses.pulse_template.AtomicPulseTemplate, arithmetic_operator: str, rhs: qupulse.pulses.pulse_template.AtomicPulseTemplate, *, silent_atomic: bool = False, measurements: List = None, identifier: str = None, registry: Optional[MutableMapping[str, Serializable]] = None)[source]

Bases: qupulse.pulses.pulse_template.AtomicPulseTemplate

Apply an operation (+ or -) channel wise to two atomic pulse templates. Channels only present in one pulse template have the operations neutral element on the other. The operations are defined in ArithmeticWaveform.operator_map.

Non-atomic pulse templates are implicitly interpreted as atomic.

Parameters
  • lhs – Left hand side operand

  • arithmetic_operator – String representation of the operator

  • rhs – Right hand side operand

  • measurements – See AtomicPulseTemplate

  • identifier – See AtomicPulseTemplate

  • registry – See qupulse.serialization.PulseRegistry

__init__(lhs: qupulse.pulses.pulse_template.AtomicPulseTemplate, arithmetic_operator: str, rhs: qupulse.pulses.pulse_template.AtomicPulseTemplate, *, silent_atomic: bool = False, measurements: List = None, identifier: str = None, registry: Optional[MutableMapping[str, Serializable]] = None)[source]

Apply an operation (+ or -) channel wise to two atomic pulse templates. Channels only present in one pulse template have the operations neutral element on the other. The operations are defined in ArithmeticWaveform.operator_map.

Non-atomic pulse templates are implicitly interpreted as atomic.

Parameters
  • lhs – Left hand side operand

  • arithmetic_operator – String representation of the operator

  • rhs – Right hand side operand

  • measurements – See AtomicPulseTemplate

  • identifier – See AtomicPulseTemplate

  • registry – See qupulse.serialization.PulseRegistry

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

Implements build_waveform().

property defined_channels

Implements defined_channels.

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

Duration of the lhs operand if it is larger zero. Else duration of the rhs.

property final_values: Dict[Union[str, int], qupulse.expressions.sympy.ExpressionScalar]

Values of defined channels at t == self.duration

get_measurement_windows(parameters: Dict[str, numbers.Real], measurement_mapping: Dict[str, Optional[str]]) List[Tuple[str, numbers.Real, numbers.Real]][source]

Calculate measurement windows with the given parameter set and rename them with the measurement mapping. This method only returns the measurement windows that are defined on self. It does _not_ collect the measurement windows defined on eventual child objects that self has/is composed of.

Parameters
  • parameters – Used to calculate the numeric begins and lengths of symbolically defined measurement windows.

  • measurement_mapping – Used to rename/drop measurement windows. Windows mapped to None are dropped.

Returns

List of measurement windows directly defined on self

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 lhs
property measurement_names

Implements measurement_names.

property parameter_names

Implements parameter_names.

property rhs
class qupulse.pulses.arithmetic_pulse_template.ArithmeticPulseTemplate(lhs: Union[qupulse.pulses.pulse_template.PulseTemplate, qupulse.expressions.ExpressionLike, Mapping[Union[str, int], qupulse.expressions.ExpressionLike]], arithmetic_operator: str, rhs: Union[qupulse.pulses.pulse_template.PulseTemplate, qupulse.expressions.ExpressionLike, Mapping[Union[str, int], qupulse.expressions.ExpressionLike]], *, identifier: Optional[str] = None, registry: Optional[MutableMapping[str, Serializable]] = None)[source]

Bases: qupulse.pulses.pulse_template.PulseTemplate

Implements the arithmetics between an aribrary pulse template and scalar values. The values can be the same for all channels, channel specific or only for a subset of the inner pulse templates defined channels. The expression may be time dependent if the pulse template is atomic.

A channel dependent scalar is represented by a mapping of ChannelID -> Expression.

The allowed operations are:

scalar + pulse_template scalar - pulse_template scalar * pulse_template pulse_template + scalar pulse_template - scalar pulse_template * scalar pulse_template / scalar

Parameters
  • lhs – Left hand side operand

  • arithmetic_operator – String representation of the operator

  • rhs – Right hand side operand

  • identifier – Identifier used for serialization

Raises
  • TypeError – If both or none of the operands are pulse templates or if there is a time dependent expression and a composite pulse template.

  • ValueError – If the scalar is a mapping and contains channels that are not defined on the pulse template.

__init__(lhs: Union[qupulse.pulses.pulse_template.PulseTemplate, qupulse.expressions.ExpressionLike, Mapping[Union[str, int], qupulse.expressions.ExpressionLike]], arithmetic_operator: str, rhs: Union[qupulse.pulses.pulse_template.PulseTemplate, qupulse.expressions.ExpressionLike, Mapping[Union[str, int], qupulse.expressions.ExpressionLike]], *, identifier: Optional[str] = None, registry: Optional[MutableMapping[str, Serializable]] = None)[source]

Implements the arithmetics between an aribrary pulse template and scalar values. The values can be the same for all channels, channel specific or only for a subset of the inner pulse templates defined channels. The expression may be time dependent if the pulse template is atomic.

A channel dependent scalar is represented by a mapping of ChannelID -> Expression.

The allowed operations are:

scalar + pulse_template scalar - pulse_template scalar * pulse_template pulse_template + scalar pulse_template - scalar pulse_template * scalar pulse_template / scalar

Parameters
  • lhs – Left hand side operand

  • arithmetic_operator – String representation of the operator

  • rhs – Right hand side operand

  • identifier – Identifier used for serialization

Raises
  • TypeError – If both or none of the operands are pulse templates or if there is a time dependent expression and a composite pulse template.

  • ValueError – If the scalar is a mapping and contains channels that are not defined on the pulse template.

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

Implements defined_channels.

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_measurement_windows(parameters: Dict[str, numbers.Real], measurement_mapping: Dict[str, Optional[str]]) List[Tuple[str, numbers.Real, numbers.Real]][source]
get_serialization_data(serializer: Optional[qupulse.serialization.Serializer] = None) Dict[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 lhs
property measurement_names: Set[str]

Implements measurement_names.

property parameter_names: Set[str]

Implements parameter_names.

property rhs
exception qupulse.pulses.arithmetic_pulse_template.ImplicitAtomicityInArithmeticPT[source]

Bases: RuntimeWarning

Signals that an ArithmeticAtomicPulseTemplate has operands that are non-atomic but will be interpreted as atomic. This is a separate class to allow easy silencing.

exception qupulse.pulses.arithmetic_pulse_template.UnequalDurationWarningInArithmeticPT[source]

Bases: RuntimeWarning

Signals that an ArithmeticAtomicPulseTemplate was constructed from operands with unequal duration. This is a separate class to allow easy silencing.

qupulse.pulses.arithmetic_pulse_template.try_operation(lhs: Union[qupulse.pulses.pulse_template.PulseTemplate, qupulse.expressions.ExpressionLike, Mapping[Union[str, int], qupulse.expressions.ExpressionLike]], op: str, rhs: Union[qupulse.pulses.pulse_template.PulseTemplate, qupulse.expressions.ExpressionLike, Mapping[Union[str, int], qupulse.expressions.ExpressionLike]], **kwargs) Union[qupulse.pulses.arithmetic_pulse_template.ArithmeticPulseTemplate, NotImplementedType][source]
Parameters
  • lhs – Left hand side operand

  • op – String representation of the operator

  • rhs – Right hand side operand

  • **kwargs – Forwarded to class init

Returns

ArithmeticPulseTemplate if the desired operation is valid and returns a pulse template NotImplemented otherwise