diff --git a/src/qibo/noise.py b/src/qibo/noise.py index d0afe8529d..013006bc44 100644 --- a/src/qibo/noise.py +++ b/src/qibo/noise.py @@ -322,19 +322,6 @@ def apply(self, circuit): if all(not isinstance(error, ReadoutError) for _, error, _ in errors_list): noisy_circuit.add(gate) - if gate.name == "measure": - readout_error_qubits = [ - qubits - for _, error, qubits in errors_list - if isinstance(error, ReadoutError) - ] - if ( - gate.qubits not in readout_error_qubits - and gate.register_name - not in noisy_circuit.measurement_tuples.keys() - ): - noisy_circuit.add(gate) - for conditions, error, qubits in errors_list: if conditions is None or all( condition(gate) for condition in conditions @@ -370,6 +357,19 @@ def apply(self, circuit): else: noisy_circuit.add(error.channel(qubits, error.options)) + if gate.name == "measure": + readout_error_qubits = [ + qubits + for _, error, qubits in errors_list + if isinstance(error, ReadoutError) + ] + if ( + gate.qubits not in readout_error_qubits + and gate.register_name + not in noisy_circuit.measurement_tuples.keys() + ): + noisy_circuit.add(gate) + return noisy_circuit diff --git a/tests/test_models_error_mitigation.py b/tests/test_models_error_mitigation.py index 035daabd1b..caaafad251 100644 --- a/tests/test_models_error_mitigation.py +++ b/tests/test_models_error_mitigation.py @@ -166,10 +166,7 @@ def test_cdr(backend, nqubits, noise, full_output, readout): else: backend.set_threads(1) - if nqubits == 1: - nmeas = 1 - else: - nmeas = nqubits - 1 + nmeas = 1 if nqubits == 1 else nqubits - 1 # Define the circuit c = get_circuit(nqubits, nmeas) # Define the observable