Skip to content

Commit

Permalink
Added a check to _combinecircs in estimator.py to prevent clash of re…
Browse files Browse the repository at this point in the history
…gister names
  • Loading branch information
SyedMustafaAhmad committed Feb 4, 2025
1 parent 1e86d65 commit 77f6f38
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion qiskit_aer/primitives/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,11 @@ def _combine_circs(circuit: QuantumCircuit, meas_circuits: list[QuantumCircuit])
circs = []
for meas_circuit in meas_circuits:
new_circ = circuit.copy()
# Track existing classical register names in new_circ
existing_creg_names = {creg.name for creg in new_circ.cregs}
for creg in meas_circuit.cregs:
new_circ.add_register(creg)
if creg.name not in existing_creg_names: # Prevent duplicate registers
new_circ.add_register(creg)
new_circ.compose(meas_circuit, inplace=True)
_update_metadata(new_circ, meas_circuit.metadata)
circs.append(new_circ)
Expand Down

0 comments on commit 77f6f38

Please sign in to comment.