Segment#

class iqm.pulse.playlist.schedule.Segment(instructions, *, duration=None)#

Bases: object

Sequence of instructions, for a single channel.

Basically a list[Instruction] that keeps track of the time duration of its contents.

Parameters:
  • instructions (Iterable[Instruction]) – contents of the segment

  • duration (int | None) – If None, compute the sum of the durations of instructions. Otherwise, the time duration (in samples) of the segment, which must match the aforementioned sum if the Segment is still to be modified.

Module: iqm.pulse.playlist.schedule

Attributes

duration

Sum of the durations of the instructions in the segment, in samples.

Methods

append

Append an instruction to the end of the segment.

copy

Make an independent copy of the segment.

extend

Append all instructions from an iterable to the end of the segment.

pop

Remove and return the instruction at the given index of the segment.

prepend

Prepend an instruction to the beginning of the segment.

_instructions: list[Instruction]#

contents

_duration: int#

total duration of the segment, in samples

copy()#

Make an independent copy of the segment.

Mutating the original must not affect the copy, or vice versa. Instructions are immutable, so they need not be copied.

Returns:

copy of the segment

Return type:

Segment

append(instruction)#

Append an instruction to the end of the segment.

Parameters:

instruction (Instruction) –

Return type:

None

prepend(instruction)#

Prepend an instruction to the beginning of the segment.

Parameters:

instruction (Instruction) –

Return type:

None

extend(instructions)#

Append all instructions from an iterable to the end of the segment.

Parameters:

instructions (Iterable[Instruction]) –

Return type:

None

pop(idx=-1)#

Remove and return the instruction at the given index of the segment.

Parameters:

idx (int) –

Return type:

Instruction

property duration: int#

Sum of the durations of the instructions in the segment, in samples.