class TestCliffordGroup: """ Test a sufficient set of conditions to prove that we have a full Clifford group for a single qubit. """ clifford = list(gates.qubit_clifford_group()) pauli = [qutip.qeye(2), qutip.sigmax(), qutip.sigmay(), qutip.sigmaz()] def test_single_qubit_group_dimension_is_24(self): assert len(self.clifford) == 24 def test_all_elements_different(self): clifford = [_remove_global_phase(gate) for gate in self.clifford] for i, gate in enumerate(clifford): for other in clifford[i + 1:]: # Big tolerance because we actually want to test the inverse. assert not np.allclose(gate.full(), other.full(), atol=1e-3) @pytest.mark.parametrize("gate", gates.qubit_clifford_group()) def test_gate_normalises_pauli_group(self, gate): """ Test the fundamental definition of the Clifford group, i.e. that it normalises the Pauli group. """ # Assert that each Clifford gate maps the set of Pauli gates back onto # itself (though not necessarily in order). This condition is no # stronger than simply considering each (gate, Pauli) pair separately. pauli_gates = [_remove_global_phase(x) for x in self.pauli] normalised = [ _remove_global_phase(gate * pauli * gate.dag()) for pauli in self.pauli ] for gate in normalised: for i, pauli in enumerate(pauli_gates): if np.allclose(gate.full(), pauli.full(), atol=1e-10): del pauli_gates[i] break assert len(pauli_gates) == 0
def test_are_cliffords(self): for U in qubit_clifford_group(): assert_(self.case_is_clifford(U))
def test_clifford_group_len(self): assert_(len(list(qubit_clifford_group())) == 24)