Concatenated

class caqtus.shot_compilation.timed_instructions.Concatenated(*instructions: TimedInstruction[T])

Bases: TimedInstruction, Generic

Represents an immutable concatenation of instructions.

Use the + operator or the function concatenate() to concatenate instructions. Do not use the class constructor directly.

property instructions: tuple[TimedInstruction[T], ...]

The instructions concatenated by this instruction.

property dtype: numpy.dtype[T]

Returns the dtype of the instruction.

as_type(
dtype: dtype,
) Concatenated

Returns a new instruction with the given dtype.

property depth: Depth

Returns the number of nested instructions.

The invariant instruction.depth <= len(instruction) always holds.

to_pattern() Pattern[T]

Returns a flattened pattern of the instruction.

apply(func: Callable[[Array1D[T]], Array1D[S]]) Concatenated[S]

Applies an element-wise function to the values of the instruction.

Parameters:

func – The function to apply to the values of the instruction. It must take a 1D numpy array with the same dtype as the instruction and return a 1D numpy array with the same length and a (possibly) different dtype.

Returns:

A new instruction with the function applied to the values. The length of the new instruction is the same as the original instruction.

Raises:

ValueError – If the function does not return an array of the same length as the one given.