3.7.1. qupulse.pulses.abstract_pulse_template

Classes

AbstractPulseTemplate(identifier, *[, ...])

This pulse template can be used as a place holder for a pulse template with a defined interface.

Exceptions

NotSpecifiedError

UnlinkWarning

class qupulse.pulses.abstract_pulse_template.AbstractPulseTemplate(identifier: str, *, defined_channels: Optional[Set[Union[str, int]]] = None, parameter_names: Optional[Set[str]] = None, measurement_names: Optional[Set[str]] = None, integral: Optional[Dict[Union[str, int], qupulse.expressions.sympy.ExpressionScalar]] = None, duration: Optional[qupulse.expressions.sympy.ExpressionScalar] = None, registry: Optional[MutableMapping[str, qupulse.serialization.Serializable]] = None)[source]

Bases: qupulse.pulses.pulse_template.PulseTemplate

This pulse template can be used as a place holder for a pulse template with a defined interface. Pulse template properties like defined_channels() can be passed on initialization to declare those properties who make up the interface. Omitted properties raise an NotSpecifiedError exception if accessed. Properties which have been accessed are marked as “frozen”.

The abstract pulse template can be linked to another pulse template by calling the link_to member. The target has to have the same properties for all properties marked as “frozen”. This ensures a property always returns the same value.

Example

>>> abstract_readout = AbstractPulseTemplate('readout', defined_channels={'X', 'Y'})
>>> assert abstract_readout.defined_channels == {'X', 'Y'}
>>> # This will raise an exception because duration is not specified
>>> print(abstract_readout.duration)
Parameters
  • identifier – Mandatory property

  • defined_channels – Optional property

  • parameter_names – Optional property

  • measurement_names – Optional property

  • integral – Optional property

  • duration – Optional property

  • registry – Instance is registered here if specified

__init__(identifier: str, *, defined_channels: Optional[Set[Union[str, int]]] = None, parameter_names: Optional[Set[str]] = None, measurement_names: Optional[Set[str]] = None, integral: Optional[Dict[Union[str, int], qupulse.expressions.sympy.ExpressionScalar]] = None, duration: Optional[qupulse.expressions.sympy.ExpressionScalar] = None, registry: Optional[MutableMapping[str, qupulse.serialization.Serializable]] = None)[source]

This pulse template can be used as a place holder for a pulse template with a defined interface. Pulse template properties like defined_channels() can be passed on initialization to declare those properties who make up the interface. Omitted properties raise an NotSpecifiedError exception if accessed. Properties which have been accessed are marked as “frozen”.

The abstract pulse template can be linked to another pulse template by calling the link_to member. The target has to have the same properties for all properties marked as “frozen”. This ensures a property always returns the same value.

Example

>>> abstract_readout = AbstractPulseTemplate('readout', defined_channels={'X', 'Y'})
>>> assert abstract_readout.defined_channels == {'X', 'Y'}
>>> # This will raise an exception because duration is not specified
>>> print(abstract_readout.duration)
Parameters
  • identifier – Mandatory property

  • defined_channels – Optional property

  • parameter_names – Optional property

  • measurement_names – Optional property

  • integral – Optional property

  • duration – Optional property

  • registry – Instance is registered here if specified

property defined_channels: Any

Abstraction of PulseTemplate.defined_channels. Raises NotSpecifiedError if the abstract template is unlinked or the property was not specified.

property duration: Any

Abstraction of PulseTemplate.duration. Raises NotSpecifiedError if the abstract template is unlinked or the property was not specified.

property final_values: Any

Abstraction of PulseTemplate.final_values. Raises NotSpecifiedError if the abstract template is unlinked or the property was not specified.

get_serialization_data(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: Any

Abstraction of PulseTemplate.initial_values. Raises NotSpecifiedError if the abstract template is unlinked or the property was not specified.

property integral: Any

Abstraction of PulseTemplate.integral. Raises NotSpecifiedError if the abstract template is unlinked or the property was not specified.

Link to another pulse template.

Parameters
  • target – Forward all getattr calls to this pulse template

  • serialize_linked – If true, serialization will be forwarded. Otherwise serialization will ignore the link

property measurement_names: Any

Abstraction of PulseTemplate.measurement_names. Raises NotSpecifiedError if the abstract template is unlinked or the property was not specified.

property parameter_names: Any

Abstraction of PulseTemplate.parameter_names. Raises NotSpecifiedError if the abstract template is unlinked or the property was not specified.

Unlink a linked target. This might lead to unexpected behaviour as forwarded get attributes are not frozen

exception qupulse.pulses.abstract_pulse_template.UnlinkWarning[source]

Bases: UserWarning