Skip to content

Commit

Permalink
Fix bug of in IonQ result conversion (#3710)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabacon committed Jan 29, 2021
1 parent ed07465 commit 18c97b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cirq/ionq/results.py
Expand Up @@ -252,7 +252,7 @@ def to_cirq_result(
[(value >> (self.num_qubits() - target - 1)) & 1 for target in targets]
for value in rand_values
]
measurements[key] = bits
measurements[key] = np.array(bits)
return study.Result(params=params or study.ParamResolver({}), measurements=measurements)

def __eq__(self, other):
Expand Down
8 changes: 8 additions & 0 deletions cirq/ionq/results_test.py
Expand Up @@ -13,6 +13,8 @@

import pytest

import numpy as np

import cirq.ionq as ionq
import cirq.testing

Expand Down Expand Up @@ -111,6 +113,9 @@ def test_qpu_result_to_cirq_result():
assert result.to_cirq_result() == cirq.Result(
params=cirq.ParamResolver({}), measurements={'x': [[0], [1], [1]]}
)
# cirq.Result only compares pandas data frame, so possible to have supplied an list of
# list instead of a numpy multidimensional array. Check this here.
assert type(result.to_cirq_result().measurements['x']) == np.ndarray


def test_qpu_result_to_cirq_result_multiple_keys():
Expand Down Expand Up @@ -277,6 +282,9 @@ def test_simulator_result_to_cirq_result():
assert result.to_cirq_result(seed=2) == cirq.Result(
params=cirq.ParamResolver({}), measurements={'x': [[1], [0], [1]]}
)
# cirq.Result only compares pandas data frame, so possible to have supplied an list of
# list instead of a numpy multidimensional array. Check this here.
assert type(result.to_cirq_result().measurements['x']) == np.ndarray


def test_simulator_result_to_cirq_result_multiple_keys():
Expand Down

0 comments on commit 18c97b3

Please sign in to comment.