Skip to content

Commit

Permalink
Ensure QuantumCircuit.metadata is always a dict (#1761)
Browse files Browse the repository at this point in the history
* Ensure QuantumCircuit.metadata is always a dict

This is for compatibility with Qiskit/qiskit#9849

* fix order

* fix typo :(

* revert object->object() change

* make backportable
  • Loading branch information
ihincks authored Mar 27, 2023
1 parent f0d02e4 commit bdd49de
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions qiskit_aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,13 @@ def _execute_circuits_job(self, circuits, noise_model, config, job_id="", format
# Take metadata from headers of experiments to work around JSON serialization error
metadata_list = []
for idx, circ in enumerate(circuits):
metadata_list.append(circ.metadata)
# TODO: we test for True-like on purpose here to condition against both None and {},
# which allows us to support versions of Terra before and after QuantumCircuit.metadata
# accepts None as a valid value. This logic should be revisited after terra>=0.24.0 is
# required.
if circ.metadata:
metadata = circ.metadata
metadata_list.append(metadata)
circ.metadata = {}
circ.metadata["metadata_index"] = idx
else:
metadata_list.append(None)
circ.metadata = {"metadata_index": idx}

# Run simulation
aer_circuits = assemble_circuits(circuits)
Expand Down

0 comments on commit bdd49de

Please sign in to comment.