qrisp.CircuitPass.compare_measurement#
- CircuitPass.compare_measurement(qc: QuantumCircuit, precision: int = 6, backend: Any = None) bool[source]#
Verify that this
CircuitPassleaves measurement statistics invariant when applied to the givenQuantumCircuit.The method copies qc, applies the pass to the copy, and then compares the measurement distributions of the original and the transformed circuit using
QuantumCircuit.run().By default, the method runs in analytic mode (no shot noise): the default backend’s
shotsoption isNone, yielding exact probability distributions of typedict[bitstring, float].- Parameters:
- qcQuantumCircuit
The input quantum circuit to test the pass against.
- precisionint, optional
The number of decimal places of agreement required between corresponding probabilities. A pair of outcomes contributes a mismatch when
abs(p_original - p_transformed) >= 10 ** -precision. The default is 6.- backendBackend or None, optional
The backend used for simulation. If
None, the Qrisp default backend is used (which runs in analytic mode withshots=None).
- Returns:
- bool
Trueif the pass preserves the measurement distribution up to the given precision,Falseotherwise.
- Raises:
- TypeError
If qc is not a
QuantumCircuit.