Skip to content

Commit

Permalink
Remove AerCircuit from result of backend.run() (#1845)
Browse files Browse the repository at this point in the history
* take AerCircuit from _metadata in experiment result

* add reno

* Fix rST formatting

---------

Co-authored-by: Jake Lishman <jake@binhbar.com>
  • Loading branch information
hhorii and jakelishman committed Jun 13, 2023
1 parent 27e3ec9 commit a598075
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion qiskit_aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def _execute_circuits_job(self, circuits, noise_model, config, job_id="", format
for result in output["results"]:
if "header" not in result:
continue
result["header"]["metadata"] = metadata_map[result["circuit"]]
result["header"]["metadata"] = metadata_map[result.pop("circuit")]

# Add execution time
output["time_taken"] = time.time() - start
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Results of ``backend.run()`` were not serializable because they include :class:`.AerCircuit`\ s.
This commit makes the results serializable by removing :class:`.AerCircuit`\ s from metadata.
3 changes: 2 additions & 1 deletion test/terra/backends/aer_simulator/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
AerSimulator Integration Tests
"""
from math import sqrt
from copy import deepcopy
from ddt import ddt
import numpy as np
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister, assemble
Expand Down Expand Up @@ -190,7 +191,7 @@ def test_metadata_protected(self):
self.assertEqual(circuit.metadata["foo"], "bar")
self.assertEqual(circuit.metadata["object"], object)

job.result()
deepcopy(job.result())

def test_run_qobj(self):
"""Test qobj run"""
Expand Down

0 comments on commit a598075

Please sign in to comment.