Skip to content

Commit

Permalink
use assertDictAlmostEqual in test_mapper (#390)
Browse files Browse the repository at this point in the history
use assertDictAlmostEqual in test_mapper
  • Loading branch information
ajavadia authored and chriseclectic committed Apr 9, 2018
1 parent d555890 commit 993b2e4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/python/test_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ def test_math_domain_error(self):
"""
self.qp.load_qasm_file(self._get_resource_path('qasm/math_domain_error.qasm'), name='test')
coupling_map = [[0, 2], [1, 2], [2, 3]]
result1 = self.qp.execute(["test"], backend="local_qasm_simulator",
coupling_map=coupling_map, seed=self.seed)

self.assertEqual(result1.get_counts("test"), {'0001': 480, '0101': 544})
shots = 2000
result = self.qp.execute("test", backend="local_qasm_simulator",
coupling_map=coupling_map,
seed=self.seed, shots=shots)
counts = result.get_counts("test")
target = {'0001': shots / 2, '0101': shots / 2}
threshold = 0.025 * shots
self.assertDictAlmostEqual(counts, target, threshold)

def test_optimize_1q_gates_issue159(self):
"""Test change in behavior for optimize_1q_gates that removes u1(2*pi) rotations.
Expand Down

0 comments on commit 993b2e4

Please sign in to comment.