From daaae525badbb655e2d0a8bfc1c5899a403205e9 Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Fri, 20 Oct 2023 14:45:28 +0100 Subject: [PATCH] Relax tolerance of `UnitaryOverlap` tests The failure rate for the parametric identity tests was about 0.2%, which at our CI scale corresponds to approximately one spurious failure every two days. The alternative to this is to fix the random seed of the test, but similar to other `quantum_info` tests, we would like some degree of extended coverage. Lifting the tolerance by three orders of magnitude at this circuit size should ensure a zero false-positive rate. This also changes the test to actually display the failure tolerance, so it's easier to tell from a CI run if a failure was real. --- test/python/circuit/library/test_overlap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/python/circuit/library/test_overlap.py b/test/python/circuit/library/test_overlap.py index 4ac765d54af8..a9a5f0ae1e2a 100644 --- a/test/python/circuit/library/test_overlap.py +++ b/test/python/circuit/library/test_overlap.py @@ -30,7 +30,7 @@ def test_identity(self): unitary.assign_parameters(np.random.random(size=unitary.num_parameters), inplace=True) overlap = UnitaryOverlap(unitary, unitary) - self.assertTrue(abs(Statevector.from_instruction(overlap)[0] - 1) < 1e-15) + self.assertLess(abs(Statevector.from_instruction(overlap)[0] - 1), 1e-12) def test_parameterized_identity(self): """Test identity is returned""" @@ -40,7 +40,7 @@ def test_parameterized_identity(self): rands = np.random.random(size=unitary.num_parameters) double_rands = np.hstack((rands, rands)) overlap.assign_parameters(double_rands, inplace=True) - self.assertTrue(abs(Statevector.from_instruction(overlap)[0] - 1) < 1e-15) + self.assertLess(abs(Statevector.from_instruction(overlap)[0] - 1), 1e-12) def test_two_parameterized_inputs(self): """Test two parameterized inputs"""