3.1.6. qupulse._program.waveforms

This module contains all waveform classes

Classes:
  • Waveform: An instantiated pulse which can be sampled to a raw voltage value array.

class qupulse._program.waveforms.Waveform[source]

Bases: qupulse.comparable.Comparable

Represents an instantiated PulseTemplate which can be sampled to retrieve arrays of voltage values for the hardware.

abstract property defined_channels

The channels this waveform should played on. Use get_measurement_windows() to get a waveform for a subset of these.

Return type

Set[Union[str, int]]

abstract property duration

The duration of the waveform in time units.

Return type

TimeType

get_sampled(channel, sample_times, output_array=None)[source]

A wrapper to the unsafe_sample method which caches the result. This method enforces the constrains unsafe_sample expects and caches the result to save memory.

Parameters
  • sample_times (ndarray) – Times at which this Waveform will be sampled.

  • output_array (Optional[ndarray]) – Has to be either None or an array of the same size and type as sample_times. If an array is given, the sampled values will be written into the given array and it will be returned. Otherwise, a new array will be created and cached to save memory.

Result:

The sampled values of this Waveform at the provided sample times. Is output_array if provided

Return type

ndarray

get_subset_for_channels(channels)[source]

Get a waveform that only describes the channels contained in channels.

Parameters

channels (AbstractSet[Union[str, int]]) – A channel set the return value should confine to.

Raises

KeyError – If channels is not a subset of the waveform’s defined channels.

Return type

Waveform

Returns

A waveform with waveform.defined_channels == channels

abstract unsafe_get_subset_for_channels(channels)[source]

Unsafe version of get_measurement_windows().

Return type

Waveform

abstract unsafe_sample(channel, sample_times, output_array=None)[source]

Sample the waveform at given sample times.

The unsafe means that there are no sanity checks performed. The provided sample times are assumed to be monotonously increasing and lie in the range of [0, waveform.duration]

Parameters
  • sample_times (ndarray) – Times at which this Waveform will be sampled.

  • output_array (Optional[ndarray]) – Has to be either None or an array of the same size and type as sample_times. If not None, the sampled values will be written here and this array will be returned

Result:

The sampled values of this Waveform at the provided sample times. Has the same number of elements as sample_times.

Return type

ndarray

class qupulse._program.waveforms.TableWaveform(channel, waveform_table)[source]

Bases: qupulse._program.waveforms.Waveform

Create a new TableWaveform instance.

Parameters

waveform_table (ImmutableList(WaveformTableEntry)) – A list of instantiated table entries of the form (time as float, voltage as float, interpolation strategy).

EntryInInit = typing.Union[qupulse._program.waveforms.TableWaveformEntry, typing.Tuple[float, float, qupulse.pulses.interpolation.InterpolationStrategy]]

Waveform obtained from instantiating a TablePulseTemplate.

__init__(channel, waveform_table)[source]

Create a new TableWaveform instance.

Parameters

waveform_table (ImmutableList(WaveformTableEntry)) – A list of instantiated table entries of the form (time as float, voltage as float, interpolation strategy).

Return type

None

property compare_key

Implements compare_key.

Return type

Any

property defined_channels

Implements defined_channels.

Return type

Set[Union[str, int]]

property duration

Implements duration.

Return type

TimeType

unsafe_get_subset_for_channels(channels)[source]

Implements unsafe_get_subset_for_channels().

Return type

Waveform

unsafe_sample(channel, sample_times, output_array=None)[source]

Implements unsafe_sample().

Return type

ndarray

class qupulse._program.waveforms.TableWaveformEntry(t, v, interp)[source]

Bases: qupulse._program.waveforms.TableWaveformEntry

Create new instance of TableWaveformEntry(t, v, interp)

class qupulse._program.waveforms.FunctionWaveform(expression, duration, channel)[source]

Bases: qupulse._program.waveforms.Waveform

Waveform obtained from instantiating a FunctionPulseTemplate.

Creates a new FunctionWaveform instance.

Parameters
  • expression (ExpressionScalar) – The function represented by this FunctionWaveform as a mathematical expression where ‘t’ denotes the time variable. It must not have other variables

  • duration (float) – The duration of the waveform

  • measurement_windows – A list of measurement windows

  • channel (Union[str, int]) – The channel this waveform is played on

__init__(expression, duration, channel)[source]

Creates a new FunctionWaveform instance.

Parameters
  • expression (ExpressionScalar) – The function represented by this FunctionWaveform as a mathematical expression where ‘t’ denotes the time variable. It must not have other variables

  • duration (float) – The duration of the waveform

  • measurement_windows – A list of measurement windows

  • channel (Union[str, int]) – The channel this waveform is played on

Return type

None

property compare_key

Implements compare_key.

Return type

Any

property defined_channels

Implements defined_channels.

Return type

Set[Union[str, int]]

property duration

Implements duration.

Return type

TimeType

unsafe_get_subset_for_channels(channels)[source]

Implements unsafe_get_subset_for_channels().

Return type

Waveform

unsafe_sample(channel, sample_times, output_array=None)[source]

Implements unsafe_sample().

Return type

ndarray

class qupulse._program.waveforms.SequenceWaveform(sub_waveforms)[source]

Bases: qupulse._program.waveforms.Waveform

This class allows putting multiple PulseTemplate together in one waveform on the hardware.

Parameters

subwaveforms – All waveforms must have the same defined channels

__init__(sub_waveforms)[source]
Parameters

subwaveforms – All waveforms must have the same defined channels

property compare_key

Implements compare_key.

Return type

Tuple[Waveform]

property defined_channels

Implements defined_channels.

Return type

Set[Union[str, int]]

property duration

Implements duration.

Return type

TimeType

unsafe_get_subset_for_channels(channels)[source]

Implements unsafe_get_subset_for_channels().

Return type

Waveform

unsafe_sample(channel, sample_times, output_array=None)[source]

Implements unsafe_sample().

Return type

ndarray

class qupulse._program.waveforms.MultiChannelWaveform(sub_waveforms)[source]

Bases: qupulse._program.waveforms.Waveform

A MultiChannelWaveform is a Waveform object that allows combining arbitrary Waveform objects to into a single waveform defined for several channels.

The number of channels used by the MultiChannelWaveform object is the sum of the channels used by the Waveform objects it consists of.

MultiChannelWaveform allows an arbitrary mapping of channels defined by the Waveforms it consists of and the channels it defines. For example, if the MultiChannelWaveform consists of a two Waveform objects A and B which define two channels each, then the channels of the MultiChannelWaveform may be 0: A.1, 1: B.0, 2: B.1, 3: A.0 where A.0 means channel 0 of Waveform object A.

The following constraints must hold:
  • The durations of all Waveform objects must be equal.

  • The channel mapping must be sane, i.e., no channel of the MultiChannelWaveform must be

    assigned more than one channel of any Waveform object it consists of

Create a new MultiChannelWaveform instance.

Requires a list of subwaveforms in the form (Waveform, List(int)) where the list defines the channel mapping, i.e., a value y at index x in the list means that channel x of the subwaveform will be mapped to channel y of this MultiChannelWaveform object.

Parameters

sub_waveforms (Iterable( Waveform )) – The list of sub waveforms of this MultiChannelWaveform

Raises
  • ValueError, if a channel mapping is out of bounds of the channels defined by this – MultiChannelWaveform

  • ValueError, if several subwaveform channels are assigned to a single channel of this – MultiChannelWaveform

  • ValueError, if subwaveforms have inconsistent durations

__init__(sub_waveforms)[source]

Create a new MultiChannelWaveform instance.

Requires a list of subwaveforms in the form (Waveform, List(int)) where the list defines the channel mapping, i.e., a value y at index x in the list means that channel x of the subwaveform will be mapped to channel y of this MultiChannelWaveform object.

Parameters

sub_waveforms (Iterable( Waveform )) – The list of sub waveforms of this MultiChannelWaveform

Raises
  • ValueError, if a channel mapping is out of bounds of the channels defined by this – MultiChannelWaveform

  • ValueError, if several subwaveform channels are assigned to a single channel of this – MultiChannelWaveform

  • ValueError, if subwaveforms have inconsistent durations

Return type

None

property compare_key

Implements compare_key.

Return type

Any

property defined_channels

Implements defined_channels.

Return type

Set[Union[str, int]]

property duration

Implements duration.

Return type

TimeType

unsafe_get_subset_for_channels(channels)[source]

Implements unsafe_get_subset_for_channels().

Return type

Waveform

unsafe_sample(channel, sample_times, output_array=None)[source]

Implements unsafe_sample().

Return type

ndarray

class qupulse._program.waveforms.RepetitionWaveform(body, repetition_count)[source]

Bases: qupulse._program.waveforms.Waveform

This class allows putting multiple PulseTemplate together in one waveform on the hardware.

property compare_key

Implements compare_key.

Return type

Tuple[Any, int]

property defined_channels

Implements defined_channels.

Return type

Set[Union[str, int]]

property duration

Implements duration.

Return type

TimeType

unsafe_get_subset_for_channels(channels)[source]

Implements unsafe_get_subset_for_channels().

Return type

RepetitionWaveform

unsafe_sample(channel, sample_times, output_array=None)[source]

Implements unsafe_sample().

Return type

ndarray

class qupulse._program.waveforms.TransformingWaveform(inner_waveform, transformation)[source]

Bases: qupulse._program.waveforms.Waveform

property compare_key

Implements compare_key.

Return type

Tuple[Waveform, Transformation]

property defined_channels

Implements defined_channels.

Return type

Set[Union[str, int]]

property duration

Implements duration.

Return type

TimeType

property inner_waveform
Return type

Waveform

property transformation
Return type

Transformation

unsafe_get_subset_for_channels(channels)[source]

Implements unsafe_get_subset_for_channels().

Return type

SubsetWaveform

unsafe_sample(channel, sample_times, output_array=None)[source]

Implements unsafe_sample().

Return type

ndarray

class qupulse._program.waveforms.ArithmeticWaveform(lhs, arithmetic_operator, rhs)[source]

Bases: qupulse._program.waveforms.Waveform

Channels only present in one waveform have the operations neutral element on the other.

property arithmetic_operator
Return type

str

property compare_key

Implements compare_key.

Return type

Tuple[str, Waveform, Waveform]

property defined_channels

Implements defined_channels.

Return type

Set[Union[str, int]]

property duration

Implements duration.

Return type

TimeType

property lhs
Return type

Waveform

numpy_operator_map = {'+': <ufunc 'add'>, '-': <ufunc 'subtract'>}
numpy_rhs_only_map = {'+': <ufunc 'positive'>, '-': <ufunc 'negative'>}
operator_map = {'+': <built-in function add>, '-': <built-in function sub>}
property rhs
Return type

Waveform

rhs_only_map = {'+': <built-in function pos>, '-': <built-in function neg>}
unsafe_get_subset_for_channels(channels)[source]

Implements unsafe_get_subset_for_channels().

Return type

Waveform

unsafe_sample(channel, sample_times, output_array=None)[source]

Implements unsafe_sample().

Return type

ndarray