Skip to content

Commit

Permalink
Relax tolerance of UnitaryOverlap tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jakelishman committed Oct 20, 2023
1 parent c4d0ea8 commit dcebece
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/python/circuit/library/test_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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"""
Expand Down

0 comments on commit dcebece

Please sign in to comment.