Skip to content

Commit eadda56

Browse files
nit
1 parent b053a93 commit eadda56

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cirq-core/cirq/experiments/z_phase_calibration_test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ def test_calibrate_z_phases(angles, error):
9393
initial_unitary = cirq.unitary(original_gate)
9494
final_unitary = cirq.unitary(calibrated_gate)
9595
target_unitary = cirq.unitary(actual_gate)
96-
assert _trace_distance(final_unitary, target_unitary) < _trace_distance(
97-
initial_unitary, target_unitary
98-
)
96+
maximally_mixed_state = np.eye(4) / 2
97+
dm_initial = initial_unitary @ maximally_mixed_state @ initial_unitary.T.conj()
98+
dm_final = final_unitary @ maximally_mixed_state @ final_unitary.T.conj()
99+
dm_target = target_unitary @ maximally_mixed_state @ target_unitary.T.conj()
100+
101+
original_dist = _trace_distance(dm_initial, dm_target)
102+
new_dist = _trace_distance(dm_final, dm_target)
103+
104+
# Either we reduced the error or the error is small enough.
105+
assert new_dist < original_dist or new_dist < 1e-6

0 commit comments

Comments
 (0)