Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure QuantumCircuit.metadata is always a dict #1761

Merged
merged 5 commits into from
Mar 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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