3.6.2. qupulse.pulses.arithmetic_pulse_template¶
-
class
qupulse.pulses.arithmetic_pulse_template.
ArithmeticAtomicPulseTemplate
(lhs, arithmetic_operator, rhs, *, silent_atomic=False, measurements=None, identifier=None, registry=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 (
AtomicPulseTemplate
) – Left hand side operandarithmetic_operator (
str
) – String representation of the operatorrhs (
AtomicPulseTemplate
) – Right hand side operandregistry (
Optional
[MutableMapping
[str
,Serializable
]]) – See qupulse.serialization.PulseRegistry
-
__init__
(lhs, arithmetic_operator, rhs, *, silent_atomic=False, measurements=None, identifier=None, registry=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 (
AtomicPulseTemplate
) – Left hand side operandarithmetic_operator (
str
) – String representation of the operatorrhs (
AtomicPulseTemplate
) – Right hand side operandregistry (
Optional
[MutableMapping
[str
,Serializable
]]) – See qupulse.serialization.PulseRegistry
-
build_waveform
(parameters, channel_mapping)[source]¶ Implements
build_waveform()
.
-
property
defined_channels
¶ Implements
defined_channels
.
-
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
-
property
duration
¶ Duration of the lhs operand if it is larger zero. Else duration of the rhs.
- Return type
-
get_measurement_windows
(parameters, measurement_mapping)[source]¶ Calculate measurement windows with the given parameter set and rename them woth the measurement mapping
-
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
- 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
lhs
¶
-
property
measurement_names
¶ Implements
measurement_names
.
-
property
parameter_names
¶ Implements
parameter_names
.
-
property
rhs
¶
-
class
qupulse.pulses.arithmetic_pulse_template.
ArithmeticPulseTemplate
(lhs, arithmetic_operator, rhs, *, identifier=None)[source]¶ Bases:
qupulse.pulses.pulse_template.PulseTemplate
- Parameters
- Raises
TypeError if both or none of the operands are pulse templates –
-
__init__
(lhs, arithmetic_operator, rhs, *, identifier=None)[source]¶ - Parameters
- Raises
TypeError if both or none of the operands are pulse templates –
-
property
defined_channels
¶ Implements
defined_channels
.
-
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
- 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
lhs
¶
-
property
measurement_names
¶ Implements
measurement_names
.
-
property
parameter_names
¶ 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, op, rhs, **kwargs)[source]¶ - Parameters
lhs (
Union
[PulseTemplate
, ~ExpressionLike,Mapping
[Union
[str
,int
], ~ExpressionLike]]) – Left hand side operandop (
str
) – String representation of the operatorrhs (
Union
[PulseTemplate
, ~ExpressionLike,Mapping
[Union
[str
,int
], ~ExpressionLike]]) – Right hand side operand**kwargs – Forwarded to class init
- Return type
Union
[ArithmeticPulseTemplate
,NotImplementedType
]- Returns
ArithmeticPulseTemplate if the desired operation is valid and returns a pulse template NotImplemented otherwise