bosing.Element

class bosing.Element

基类:object

Base class for schedule elements.

A schedule element is a node in the tree structure of a schedule similar to HTML elements. The design is inspired by XAML in WPF / WinUI

Every element has the following properties:

  • margin

    The margin of an element is a tuple of two floats representing the margin before and after the element. If margin is set to a single float, both sides use the same value.

    Similar to margins in XAML, margins don't collapse. For example, if two elements have a margin of 10 and 20, the space between the two elements is 30, not 20.

  • alignment

    The alignment of the element. Currently, this property takes effect only when the element is a child of a Grid element.

  • phantom

    Whether the element is a phantom element. Phantom elements are measured and arranged in the layout but do not add to the waveforms.

  • duration, max_duration, and min_duration

    Constraints on the duration of the element. When duration, max_duration, and min_duration are conflicting, the priority is as follows:

    1. min_duration

    2. max_duration

    3. duration

    When duration is not set, the duration is calculated such that the element occupies the minimum duration.

There are two types of elements:

  • Instruction elements:

    Elements that instruct the waveform generator to perform certain operations, such as playing a pulse or setting the phase of a channel.

    • Play: Play a pulse on a channel.

    • ShiftPhase: Shift the phase of a channel.

    • SetPhase: Set the phase of a channel.

    • ShiftFreq: Shift the frequency of a channel.

    • SetFreq: Set the frequency of a channel.

    • SwapPhase: Swap the phase of two channels.

    The timing information required by the waveform generator is calculated by the layout system.

  • Layout elements:

    Elements that control the layout of child elements.

参数:
  • margin (float | tuple[float, float]) -- Margin of the element. Defaults to 0.

  • alignment (str | Alignment) -- Alignment of the element. The value can be Alignment or one of 'end', 'start', 'center', 'stretch'. Defaults to Alignment.End.

  • phantom (bool) -- Whether the element is a phantom element and should not add to waveforms. Defaults to False.

  • duration (float) -- Duration of the element. Defaults to None.

  • max_duration (float) -- Maximum duration of the element. Defaults to inf.

  • min_duration (float) -- Minimum duration of the element. Defaults to 0.

  • label (str | None) -- Label of the element. Defaults to None.

alignment
duration
label
margin
max_duration
measure()

Measure the minimum total duration required by the element.

This value includes both inner duration and outer margin of the element.

This value is a minimum total duration wanted by the element. If the element is a child of other element, the final total duration will be determined by alignment option and parent container type.

min_duration
phantom
plot(ax=None, *, channels=None, max_depth=5, show_label=True)

Plot arrange result with the element as root.

参数:
  • ax (matplotlib.axes.Axes | None) -- Axes to plot. If None, matplotlib.pyplot.gca is used.

  • channels (Sequence[str] | None) -- Channels to plot. If None, all channels are plotted.

  • max_depth (int) -- Maximum depth to plot. Defaults to 5.

  • show_label (bool) -- Whether to show label of elements. Defaults to True.

返回:

Axes with the plot.

返回类型:

matplotlib.axes.Axes