Skip to main content
IBM Quantum Platform

filter_annotations

samplomatic.utils.filter_annotations(circuit: QuantumCircuit, keep: type[Annotation] | tuple[type[Annotation], ...]) → QuantumCircuit

GitHub

Return a new circuit keeping only annotations of the given type(s) on each box.

Parameters

  • circuit – The circuit whose box annotations to filter.
  • keep – Annotation type or tuple of types to retain.

Returns

A new circuit where each box’s annotations contain only instances of keep.

from qiskit.circuit import QuantumCircuit
from samplomatic import Twirl, InjectNoise
from samplomatic.utils import filter_annotations

circuit = QuantumCircuit(2)
with circuit.box([Twirl(), InjectNoise("ref")]):
    circuit.cx(0, 1)

twirl_only = filter_annotations(circuit, Twirl)
Was this page helpful?
Report a bug, typo, or request content on GitHub.