def test_circuit_is_not_mutated_by_executors(): single_qubit_circ = QuantumCircuit(1, 1) single_qubit_circ.z(0) expected_circuit = single_qubit_circ.copy() execute_with_shots_and_noise( circuit=single_qubit_circ, obs=ONE_QUBIT_GS_PROJECTOR, noise_model=initialized_depolarizing_noise(NOISE), shots=SHOTS, ) assert single_qubit_circ.data == expected_circuit.data assert single_qubit_circ == expected_circuit execute_with_noise( circuit=single_qubit_circ, obs=ONE_QUBIT_GS_PROJECTOR, noise_model=initialized_depolarizing_noise(NOISE), ) assert single_qubit_circ.data == expected_circuit.data assert single_qubit_circ == expected_circuit
def test_execute_with_depolarizing_noise_two_qubit(): """Tests the noisy sampling executor across increasing levels of two qubit gate noise. """ two_qubit_circ = QuantumCircuit(2) # noise model is defined on gates so include the gate to # demonstrate noise two_qubit_circ.cx(0, 1) noiseless_exp_value = 1.0 expectation_value = execute_with_noise( circuit=two_qubit_circ, obs=TWO_QUBIT_GS_PROJECTOR, noise_model=initialized_depolarizing_noise(NOISE), ) # anticipate that the expectation value will be less than # the noiseless simulation of the same circuit assert expectation_value < noiseless_exp_value