Skip to content

Commit

Permalink
Change level 1 memory result data type to match Qiskit
Browse files Browse the repository at this point in the history
In Qiskit, it is specified that memory should be a list
(https://github.com/Qiskit/qiskit/blob/b9d5c9c6aeb4568b6e9fba8943517ebed300886d/qiskit/result/models.py#L38).
While most code can work with either lists or numpy arrays, some can
not, including BackendSamplerV2 in Qiskit (see
qiskit-community/qiskit-experiments#1487).
Here the numpy array data is converted to a nested list using
`tolist()`.
  • Loading branch information
wshanks committed Nov 15, 2024
1 parent 6b54df2 commit 0aa3eff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion qiskit_dynamics/backend/dynamics_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def default_experiment_result_function(
measurement_data = np.average(measurement_data, axis=0)

# construct results object
exp_data = ExperimentResultData(memory=measurement_data)
exp_data = ExperimentResultData(memory=measurement_data.tolist())
return ExperimentResult(
shots=backend.options.shots,
success=True,
Expand Down
8 changes: 8 additions & 0 deletions releasenotes/notes/level1list-6564aec23c46bf7a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
fixes:
- |
The data type of memory data produced by :class:`~.DynamicsBackend` for
measurement level 1 was changed from a Numpy array to a list in order to
match the type documented for the ``ExperimentResultData`` class in Qiskit.
To get the old Numpy format back, it is sufficient to call ``numpy.array``
on the result data.

0 comments on commit 0aa3eff

Please sign in to comment.