0
$\begingroup$

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.

New contributor
user184655 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

0

Your Answer

user184655 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.