state_preparation_error
- GateCompiler.state_preparation_error(target_state, compiled, initial_state=None)
Return the error of a compiled preparation against the state it should produce.
The unitary counterpart is
compilation_error(). A preparation is compared on one state instead, so the two numbers are not comparable.- Parameters:
target_state (
Any) – State the circuit should prepare.compiled (
QuantumCircuit) – Circuit returned bycompile_state().initial_state (
Any) – State the circuit is run from, in the same formcompile_state()takes it. Pass the one the preparation was compiled for;Nonemeans the all-zero state.
- Return type:
- Returns:
One minus the fidelity of the produced state with the target. 0 is a perfect match; larger is worse.
- Raises:
ValidationError – If a state’s norm is not 1, or
compiledholds a Pauli readout, a reset or a measurement.