I'm trying to find the expectation value of an operator using a noisy circuit and this is the code I found:
obs = Observable(PauliString("Z"))
prob_1 = 0.005
prob_2 = 0.01
error_1 = noise.depolarizing_error(prob_1, 1)
noise_model = noise.NoiseModel()
noise_model.add_all_qubit_quantum_error(error_1, ['u1', 'u2', 'u3'])
def sim_noise(qc, obs : npt.NDArray[np.complex64])-> float:
return execute_with_shots_and_noise(qc, obs, noise_model , 4096)
def sim(qc, obs : npt.NDArray[np.complex64])-> float:
return execute_with_shots(qc, obs, 4096)
ideal_measurement = obs.expectation(get_circuit(), sim_noise).real.
I keep getting this error:
ValueError: Executor and observable are not compatible. Executors
returning expectation values as float must be used with
observable=None.
I couldn't figure out how to fix it.