Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Feb 27, 2024
1 parent 21908e3 commit 05bab4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
26 changes: 13 additions & 13 deletions src/qibo/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down
5 changes: 1 addition & 4 deletions tests/test_models_error_mitigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05bab4b

Please sign in to comment.