qrisp.CircuitPass.compare_unitary#
- CircuitPass.compare_unitary(qc: QuantumCircuit, precision: int = 4, ignore_gphase: bool = False) bool[source]#
Verify that this
CircuitPassleaves the unitary invariant when applied to the givenQuantumCircuit.The method copies qc, applies the pass to the copy, and then compares the original and transformed unitaries using
QuantumCircuit.compare_unitary().Measurements are not allowed because they break unitarity and would cause the underlying unitary computation to fail.
- Parameters:
- qcQuantumCircuit
The input quantum circuit to test the pass against.
- precisionint, optional
The precision passed to
QuantumCircuit.compare_unitary(). The default is 4.- ignore_gphasebool, optional
If
True, ignore global phase differences. The default isFalse.
- Returns:
- bool
Trueif the pass preserves the unitary up to the given precision,Falseotherwise.
- Raises:
- TypeError
If qc is not a
QuantumCircuit.- ValueError
If either the input or the transformed circuit contains measurement instructions.