CircuitPass#
- class CircuitPass(func: Callable[[QuantumCircuit], QuantumCircuit])[source]#
A decorator for quantum circuit transformation passes.
CircuitPasswraps a callable with signatureQuantumCircuit -> QuantumCircuitand enforces type safety by checking that both the argument and the return value areQuantumCircuitinstances.It can be used as a bare decorator on a pass function, or instantiated explicitly with a function reference. Either way, the resulting
CircuitPassobject is itself callable and forwards calls to the wrapped function after performing the type checks.Examples
Using
CircuitPassas a decorator:@CircuitPass def my_pass(qc): # transform qc return qc
Wrapping an existing function explicitly:
from qrisp import CircuitPass, fuse_adjacents typed_pass = CircuitPass(fuse_adjacents) result = typed_pass(qc)
Inside factory functions that return configured passes:
def convert_to_cz(strict=False): @CircuitPass def _convert_to_cz(qc): ... return _convert_to_cz
Methods#
|
Verify that this |
|
Verify that this |
Print a before/after visualisation of this pass applied to qc. |