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)
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_fragment | The ending fragment. |
fragment_depth | The number of repetitions of the repeatable fragment. |
gate_key | A hashable summary of the gate applications in this instruction sequence. |
is_complete | Whether all contained instructions are completely specified. |
is_unbound | Whether the sequence is unbound. |
repeatable_fragment | The repeatable fragment. |
start_fragment | The starting fragment. |
structure_key | A 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.