3.6.1. qupulse.program.loop

Functions

_is_compatible(program, min_len, quantum, ...)

check whether program loop is compatible with awg requirements possible reasons for incompatibility: program shorter than minimum length program duration not an integer program duration not a multiple of quantum

_make_compatible(program, min_len, quantum, ...)

_repeat_loop_measurements(begin_length_list, ...)

make_compatible(program, ...)

check program for compatibility to AWG requirements, make it compatible if necessary and possible

roll_constant_waveforms(program, ...)

This function finds waveforms in program that can be replaced with repetitions of shorter waveforms and replaces them.

to_waveform(program)

Classes

Loop([parent, children, waveform, ...])

Initialize a new loop

_CompatibilityLevel(value)

An enumeration.

Exceptions

DroppedMeasurementWarning

This warning is emitted if a measurement was dropped because there was no waveform attached.

MakeCompatibleWarning

VolatileModificationWarning

This warning is emitted if the colatile part of a program gets modified.

class qupulse.program.loop.Loop(parent: Optional[qupulse.program.loop.Loop] = None, children: Iterable[qupulse.program.loop.Loop] = (), waveform: Optional[qupulse.program.waveforms.Waveform] = None, measurements: Optional[List[Tuple[str, numbers.Real, numbers.Real]]] = None, repetition_count: Union[int, qupulse.program.volatile.VolatileRepetitionCount] = 1)[source]

Bases: qupulse.utils.tree.Node

Initialize a new loop

Parameters
  • parent – Forwarded to Node.__init__

  • children – Forwarded to Node.__init__

  • waveform – “Payload”

  • measurements – Associated measurements

  • repetition_count – The children / waveform are repeated this often

MAX_REPR_SIZE = 2000
__init__(parent: Optional[qupulse.program.loop.Loop] = None, children: Iterable[qupulse.program.loop.Loop] = (), waveform: Optional[qupulse.program.waveforms.Waveform] = None, measurements: Optional[List[Tuple[str, numbers.Real, numbers.Real]]] = None, repetition_count: Union[int, qupulse.program.volatile.VolatileRepetitionCount] = 1)[source]

Initialize a new loop

Parameters
  • parent – Forwarded to Node.__init__

  • children – Forwarded to Node.__init__

  • waveform – “Payload”

  • measurements – Associated measurements

  • repetition_count – The children / waveform are repeated this often

add_measurements(measurements: Iterable[Tuple[str, numbers.Real, numbers.Real]])[source]

Add measurements offset by the current body duration i.e. to the END of the current loop

Parameters

measurements – Measurements to add

append_child(loop: Optional[qupulse.program.loop.Loop] = None, **kwargs) None[source]

Append a child to this loop. Either an existing Loop object or a newly created from kwargs

Parameters
  • loop – loop to append

  • **kwargs – Child is constructed with these kwargs

Raises

ValueError – if called with loop and kwargs

property body_duration: qupulse.utils.types.TimeType
cleanup(actions=('remove_empty_loops', 'merge_single_child'))[source]

Apply the specified actions to cleanup the Loop.

remove_empty_loops: Remove loops with no children and no waveform (a DroppedMeasurementWarning is issued) merge_single_child: see _try_merge_single_child documentation

Warning

DroppedMeasurementWarning: Likely a bug in qupulse. TODO: investigate whether there are usecases

copy_tree_structure(new_parent: Union[qupulse.program.loop.Loop, bool] = False) qupulse.program.loop.Loop[source]
property duration: qupulse.utils.types.TimeType
encapsulate() None[source]

Add a nesting level by moving self to its children.

flatten_and_balance(depth: int) None[source]

Modifies the program so all tree branches have the same depth.

Parameters

depth – Target depth of the program

get_duration_structure() Tuple[int, Union[qupulse.utils.types.TimeType, Tuple[int, Union[qupulse.utils.types.TimeType, DurationStructure]]]][source]

Returns a tuple that fingerprints the structure of waveform durations and repetitions of self.

One possible use case is to identify repeated duration structures and reuse the same control flow with differing data.

get_measurement_windows(drop=False) Dict[str, Tuple[numpy.ndarray, numpy.ndarray]][source]

Iterates over all children and collect the begin and length arrays of each measurement window.

Parameters
  • drop – Drops the measurements from the Loop i.e. the Loop will no longer have measurements attached after

  • them. (collecting) –

Returns

A dictionary (measurement_name -> (begin, length)) with begin and length being numpy.ndarray

property repetition_count: int
property repetition_definition: Union[int, qupulse.program.volatile.VolatileRepetitionCount]
reverse_inplace()[source]
split_one_child(child_index=None) None[source]

Take the last child that has a repetition count larger one, decrease it’s repetition count and insert a copy with repetition cout one after it

unroll() None[source]
unroll_children() None[source]
property volatile_repetition: Optional[qupulse.program.volatile.VolatileProperty]
property waveform: qupulse.program.waveforms.Waveform
exception qupulse.program.loop.MakeCompatibleWarning[source]

Bases: ResourceWarning

qupulse.program.loop.make_compatible(program: qupulse.program.loop.Loop, minimal_waveform_length: int, waveform_quantum: int, sample_rate: qupulse.utils.types.TimeType)[source]

check program for compatibility to AWG requirements, make it compatible if necessary and possible

qupulse.program.loop.to_waveform(program: qupulse.program.loop.Loop) qupulse.program.waveforms.Waveform[source]