Skip to main content
IBM Quantum Platform

qiskit_noise_learning.sequences.InstructionSequence

class qiskit_noise_learning.sequences.InstructionSequence(start_fragment: Iterable[T], repeatable_fragment: Iterable[T], end_fragment: Iterable[T], fragment_depth: int | None = None)

GitHub

Bases: BaseSequence[Instruction]

A sequence of instructions.

Parameters

  • start_fragment – The start of the sequence.
  • repeatable_fragment – The repeatable middle of the sequence.
  • end_fragment – The end of the sequence.
  • fragment_depth – The number of repetitions of the repeatable fragment.

__init__

__init__(start_fragment: Iterable[T], repeatable_fragment: Iterable[T], end_fragment: Iterable[T], fragment_depth: int | None = None)


Methods

Column 1
Column 2
__init__(start_fragment, ...[, fragment_depth])
bind_at(fragment_depth)Return a new instance with the same fragments bound to the fragment depth.
complete()Return a new instance whose data is the same as self except that all contained instructions are completed.
is_mergeable_with(other)Check if this instruction sequence is mergeable with another instruction sequence.
merge(other)Merge this instruction sequence with another instruction sequence.
unbind()Return a new instance with the same fragments but fragment depth set to None.

Attributes

Column 1
Column 2
end_fragmentThe ending fragment.
fragment_depthThe number of repetitions of the repeatable fragment.
gate_keyA hashable summary of the gate applications in this instruction sequence.
is_completeWhether all contained instructions are completely specified.
is_unboundWhether the sequence is unbound.
repeatable_fragmentThe repeatable fragment.
start_fragmentThe starting fragment.
structure_keyA hashable summary of the instruction structure of this sequence.

is_complete

Type: bool

Whether all contained instructions are completely specified.

complete

complete() → Self

Return a new instance whose data is the same as self except that all contained instructions are completed.

Returns

A new InstructionSequence instance.

gate_key

Type: Hashable

A hashable summary of the gate applications in this instruction sequence.

Two instruction sequences have equal gate keys exactly when they have the same fragment depth and each of their fragments applies the same gates in the same order, however else they differ; every instruction that is not a gate application is ignored. The value itself is opaque, with only equality and hashability guaranteed.

structure_key

Type: Hashable

A hashable summary of the instruction structure of this sequence.

This key comes with the following guarantees:

  • If two instruction sequences have different keys, they are not mergeable.
  • If two instruction sequences have the same key, they have the same fragment depth, and their fragments contain the same sequence of instruction types on the same qubits.

Raises

TypeError – If this instruction sequence contains an object that is not an instruction.

is_mergeable_with

is_mergeable_with(other: Self) → bool

Check if this instruction sequence is mergeable with another instruction sequence.

Two instruction sequences are mergeable if they have compatible fragment depths and their fragments are element-wise mergeable.

Parameters

other – The other InstructionSequence.

Returns

Whether this instance is mergeable with another.

merge

merge(other: Self) → Self

Merge this instruction sequence with another instruction sequence.

Assuming this instance is mergeable with other, the returned merged sequence is constructed by merging each corresponding fragment element-wise.

Parameters

other – The instruction sequence to merge this with.

Returns

The merged sequence of self and other.

Raises

ValueError – If the sequences are not mergeable.

Was this page helpful?
Report a bug, typo, or request content on GitHub.