Skip to content

Commit

Permalink
Remove zero-probability states from Sampler's result (Qiskit/qiskit#9248
Browse files Browse the repository at this point in the history
)

* Remove zero probability from Sampler's result

* fix TestGrover

* add reno

* fix a test

* round probabilities

Co-authored-by: Julien Gacon <[email protected]>
Co-authored-by: Ikko Hamamura <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 19, 2023
1 parent 7c91f83 commit 25e84e1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/test_grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,11 @@ def test_circuit_result(self, use_sampler):
if use_sampler:
for i, dist in enumerate(result.circuit_results):
keys, values = zip(*sorted(dist.items()))
self.assertTupleEqual(keys, ("00", "01", "10", "11"))
if i in (0, 3):
np.testing.assert_allclose(values, [0, 0, 0, 1], atol=0.2)
self.assertTupleEqual(keys, ("11",))
np.testing.assert_allclose(values, [1], atol=0.2)
else:
self.assertTupleEqual(keys, ("00", "01", "10", "11"))
np.testing.assert_allclose(values, [0.25, 0.25, 0.25, 0.25], atol=0.2)
else:
expected_results = [
Expand Down

0 comments on commit 25e84e1

Please sign in to comment.