Skip to content

Commit b42d8ce

Browse files
Relax inexact FP test of PauliLindbladMap (Qiskit#15108) (Qiskit#15109)
This has been slightly flaky in CI, because some of the assertions are for exact floating-point equality through a fairly complex special function, which isn't guaranteed to any overly precise rounding. (cherry picked from commit 595a089) Co-authored-by: Jake Lishman <[email protected]>
1 parent 6184f89 commit b42d8ce

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

test/python/quantum_info/test_pauli_lindblad_map.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,21 +1122,21 @@ def test_pauli_fidelity(self):
11221122
[("XY", [0, 1], 1.23), ("Z", [1], -0.23), ("X", [2], 0.3)], num_qubits=4
11231123
)
11241124
self.assertEqual(pauli_lindblad_map.pauli_fidelity(QubitSparsePauli(("X", [0]), 4)), 1.0)
1125-
self.assertEqual(
1126-
pauli_lindblad_map.pauli_fidelity(QubitSparsePauli(("Y", [0]), 4)), np.exp(-2 * 1.23)
1125+
np.testing.assert_array_max_ulp(
1126+
pauli_lindblad_map.pauli_fidelity(QubitSparsePauli(("Y", [0]), 4)),
1127+
np.exp(-2 * 1.23),
1128+
maxulp=3,
11271129
)
1128-
self.assertEqual(
1129-
pauli_lindblad_map.pauli_fidelity(QubitSparsePauli(("X", [1]), 4)), np.exp(-2 * 1.0)
1130+
np.testing.assert_array_max_ulp(
1131+
pauli_lindblad_map.pauli_fidelity(QubitSparsePauli(("X", [1]), 4)),
1132+
np.exp(-2 * 1.0),
1133+
maxulp=3,
11301134
)
11311135
self.assertEqual(pauli_lindblad_map.pauli_fidelity(QubitSparsePauli(("Z", [3]), 4)), 1.0)
1132-
# np.allclose needed for machine precision
1133-
self.assertTrue(
1134-
np.allclose(
1135-
pauli_lindblad_map.pauli_fidelity(QubitSparsePauli(("ZXY", [0, 1, 2]), 4)),
1136-
np.exp(-2 * 0.07),
1137-
atol=1e-12,
1138-
rtol=1e-12,
1139-
)
1136+
np.testing.assert_array_max_ulp(
1137+
pauli_lindblad_map.pauli_fidelity(QubitSparsePauli(("ZXY", [0, 1, 2]), 4)),
1138+
np.exp(-2 * 0.07),
1139+
maxulp=3,
11401140
)
11411141

11421142
self.assertEqual(

0 commit comments

Comments
 (0)