qrisp.CircuitPass.compare_measurement#

CircuitPass.compare_measurement(qc: QuantumCircuit, precision: int = 6, backend: Any = None) bool[source]#

Verify that this CircuitPass leaves measurement statistics invariant when applied to the given QuantumCircuit.

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 shots option is None, yielding exact probability distributions of type dict[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 with shots=None).

Returns:
bool

True if the pass preserves the measurement distribution up to the given precision, False otherwise.

Raises:
TypeError

If qc is not a QuantumCircuit.