From 80b6f75f22528ec5c47cf7b92a7e49b46801d826 Mon Sep 17 00:00:00 2001 From: Ali Javadi Date: Fri, 6 Apr 2018 23:32:31 -0400 Subject: [PATCH 1/2] use assertDictAlmostEqual in test_mapper lint --- test/python/test_mapper.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/python/test_mapper.py b/test/python/test_mapper.py index 426712926033..56b5b47a4c07 100644 --- a/test/python/test_mapper.py +++ b/test/python/test_mapper.py @@ -52,10 +52,13 @@ 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}) + result = self.qp.execute("test", backend="local_qasm_simulator", + coupling_map=coupling_map, + seed=self.seed, shots=1024) + counts = result.get_counts("test") + target = {'0001': 480, '0101': 544} + threshold = 0.025 * 1024 + 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. From c9c34b97df1f4ec17aada56e29f7dbbf1c8039d0 Mon Sep 17 00:00:00 2001 From: Ali Javadi Date: Mon, 9 Apr 2018 13:21:35 -0400 Subject: [PATCH 2/2] fixing expected target in test_mapper --- test/python/test_mapper.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/python/test_mapper.py b/test/python/test_mapper.py index 56b5b47a4c07..67f0a157df37 100644 --- a/test/python/test_mapper.py +++ b/test/python/test_mapper.py @@ -52,12 +52,13 @@ 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]] + shots = 2000 result = self.qp.execute("test", backend="local_qasm_simulator", coupling_map=coupling_map, - seed=self.seed, shots=1024) + seed=self.seed, shots=shots) counts = result.get_counts("test") - target = {'0001': 480, '0101': 544} - threshold = 0.025 * 1024 + target = {'0001': shots / 2, '0101': shots / 2} + threshold = 0.025 * shots self.assertDictAlmostEqual(counts, target, threshold) def test_optimize_1q_gates_issue159(self):