Skip to content

Commit fc464b6

Browse files
authored
Change level 1 memory result data type to match Qiskit (#367)
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()`.
1 parent e494205 commit fc464b6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

qiskit_dynamics/backend/dynamics_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ def default_experiment_result_function(
920920
measurement_data = np.average(measurement_data, axis=0)
921921

922922
# construct results object
923-
exp_data = ExperimentResultData(memory=measurement_data)
923+
exp_data = ExperimentResultData(memory=measurement_data.tolist())
924924
return ExperimentResult(
925925
shots=backend.options.shots,
926926
success=True,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
fixes:
3+
- |
4+
The data type of memory data produced by :class:`~.DynamicsBackend` for
5+
measurement level 1 was changed from a Numpy array to a list in order to
6+
match the type documented for the ``ExperimentResultData`` class in Qiskit.
7+
To get the old Numpy format back, it is sufficient to call ``numpy.array``
8+
on the result data.

0 commit comments

Comments
 (0)