3.5.2. qupulse.program.loop¶
Program builder implementation that creates the legacy Loop.
Functions
|
check program for compatibility to AWG requirements, make it compatible if necessary and possible |
|
This function finds waveforms in program that can be replaced with repetitions of shorter waveforms and replaces them. |
|
Classes
|
Initialize a new loop |
|
Notes fduring implementation: |
|
|
|
Exceptions
|
This warning is emitted if a measurement was dropped because there was no waveform attached. |
- class Loop(parent: Loop | None = None, children: Iterable[Loop] = (), waveform: Waveform | None = None, measurements: List[Tuple[str, Real, Real]] | None = None, repetition_count: int | VolatileRepetitionCount = 1)[source]¶
Bases:
NodeInitialize 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¶
- add_measurements(measurements: Iterable[Tuple[str, Real, 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: Loop | None = 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
- 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
- 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_defined_channels() AbstractSet[str | int][source]¶
- get_duration_structure() Tuple[int, TimeType | Tuple[int, 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[ndarray, 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
- get_waveforms_dict(channels: Sequence[str | int], channel_transformations: Mapping[str | int, ChannelTransformation]) Mapping[Waveform, Any][source]¶
- property repetition_definition: int | VolatileRepetitionCount¶
- 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
- property volatile_repetition: VolatileProperty | None¶
- class LoopBuilder(initial_context: BuildContext = None, initial_settings: BuildSettings = None)[source]¶
Bases:
BaseProgramBuilder- Notes fduring implementation:
This program builder does not use the Loop class to generate the measurements
- measure(measurements: Sequence[Tuple[str, Real, Real]] | None)[source]¶
Unconditionally add given measurements relative to the current position.
- Parameters:
measurements – Measurements to add.
- new_subprogram(global_transformation: Transformation = None) Iterator[ProgramBuilder][source]¶
Create a context managed program builder whose contents are translated into a single waveform upon exit if it is not empty.
- Returns:
A context manager that returns a
ProgramBuilderon entering.
- time_reversed() Iterator[ProgramBuilder][source]¶
This returns a new context manager that will reverse everything added to it in time upon exit.
- Returns:
A context manager that returns a
ProgramBuilderon entering.
- to_program() Loop | None[source]¶
Generate the final program. This is allowed to invalidate the program builder.
- Returns:
A program implementation. None if nothing was added to this program builder.
- with_iteration(index_name: str, rng: range, measurements: Sequence[Tuple[str, Real, Real]] | None = None) Iterable[ProgramBuilder][source]¶
Create an iterable that represent the body of the iteration. This can be an iterable with an element for each step in the iteration or a single object that represents the complete iteration.
- Parameters:
index_name – The name of index
rng – The range if the index
measurements – Measurements to add iff the iteration body is not empty.
- with_repetition(repetition_count: int | VolatileRepetitionCount | DynamicLinearValue[int], measurements: Sequence[Tuple[str, Real, Real]] | None = None) Iterable[ProgramBuilder][source]¶
Start a new repetition context with given repetition count. The caller has to iterate over the return value and call :py:meth:.ProgramBuilder.inner_scope` inside the iteration context.
- Parameters:
repetition_count – Repetition count
measurements – These measurements are added relative to the position at the start of the iteration iff the iteration is not empty.
- Returns:
An iterable of
ProgramBuilderinstances.
- with_sequence(measurements: Sequence[Tuple[str, Real, Real]] | None = None) Iterator[ProgramBuilder][source]¶
Start a new sequence context. The caller has to enter the returned context manager and add the sequenced elements there.
Measurements that are added in to the returned program builder are discarded if the sequence is empty on exit.
- Parameters:
measurements – These measurements are added relative to the position at the start of the sequence iff the
empty. (sequence is not)
- Returns:
A context manager that returns a
ProgramBuilderon entering.
- exception MakeCompatibleWarning[source]¶
Bases:
ResourceWarning