Skip to content

Commit 9be3231

Browse files
authored
Fix the typo in clifford_gate_test::test_commutes_pauli (quantumlib#4149)
Although the original test is still theoretically correct, it doesn't make sense to make the expected result with an exponent but call the actual `commutes` function without an exponent. And I guess 0.1 was a typo for 1.0. There was another error revealed when I tried to fix it -- `cirq.allclose_up_to_global_phase(mat, mat_swap)`. "Up to gloabl phase" means both commutive and anti-commutive operators return ture, which is not desired.
1 parent 0ac6cc1 commit 9be3231

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cirq/ops/clifford_gate_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def test_commutes_single_qubit_gate(gate, other):
445445

446446
@pytest.mark.parametrize(
447447
'gate,pauli,half_turns',
448-
itertools.product(_all_clifford_gates(), _paulis, (0.1, 0.25, 0.5, -0.5)),
448+
itertools.product(_all_clifford_gates(), _paulis, (1.0, 0.25, 0.5, -0.5)),
449449
)
450450
def test_commutes_pauli(gate, pauli, half_turns):
451451
pauli_gate = pauli ** half_turns
@@ -458,8 +458,8 @@ def test_commutes_pauli(gate, pauli, half_turns):
458458
pauli_gate(q0),
459459
gate(q0),
460460
).unitary()
461-
commutes = cirq.commutes(gate, pauli)
462-
commutes_check = cirq.allclose_up_to_global_phase(mat, mat_swap)
461+
commutes = cirq.commutes(gate, pauli_gate)
462+
commutes_check = np.allclose(mat, mat_swap)
463463
assert commutes == commutes_check
464464

465465

0 commit comments

Comments
 (0)