diff --git a/qermit/coherent_pauli_checks/pauli_sampler.py b/qermit/coherent_pauli_checks/pauli_sampler.py index dd07653a..6da63035 100644 --- a/qermit/coherent_pauli_checks/pauli_sampler.py +++ b/qermit/coherent_pauli_checks/pauli_sampler.py @@ -238,7 +238,6 @@ def sample( :return: Random Pauli of length equal to the size of the circuit. """ # TODO: Make sure sampling is done without replacement - stabiliser_list: List[QermitPauli] = [] while len(stabiliser_list) < self.n_checks: Z_list = [self.rng.integers(2) for _ in circ.qubits] diff --git a/qermit/noise_model/qermit_pauli.py b/qermit/noise_model/qermit_pauli.py index 94c852d9..40e353c8 100644 --- a/qermit/noise_model/qermit_pauli.py +++ b/qermit/noise_model/qermit_pauli.py @@ -7,7 +7,8 @@ import numpy as np from numpy.random import Generator from pytket.circuit import Circuit, Op, OpType, Qubit -from pytket.pauli import Pauli, QubitPauliString, QubitPauliTensor +from pytket.pauli import Pauli, QubitPauliString, QubitPauliTensor, pauli_string_mult +from pytket.tableau import UnitaryTableau class QermitPauli: @@ -93,7 +94,6 @@ def dagger(self) -> QermitPauli: :return: Conjugate transpose of the Pauli. """ - return QermitPauli.from_qubit_pauli_tensor( qpt=QubitPauliTensor( string=self.qubit_pauli_tensor.string, @@ -428,10 +428,10 @@ def get_control_circuit(self, control_qubit: Qubit) -> Circuit: ) if pauli == Pauli.Y: - phase += 2 + phase += 1 phase %= 4 - for _ in range(self.phase): + for _ in range(phase): circ.S( control_qubit, opgroup="phase correction", @@ -460,10 +460,10 @@ def circuit(self) -> Circuit: circ.X(qubit) if pauli == Pauli.Y: - phase += 2 + phase += 1 phase %= 4 - circ.add_phase(a=self.phase / 2) + circ.add_phase(a=phase / 2) return circ diff --git a/tests/noise_model_test.py b/tests/noise_model_test.py index 45c04a2a..8fd3c8d0 100644 --- a/tests/noise_model_test.py +++ b/tests/noise_model_test.py @@ -558,7 +558,7 @@ def test_qermit_pauli_circuit() -> None: L = QermitPauli(Z_list=[1, 1, 1], X_list=[0, 0, 0], qubit_list=circ.qubits) L_circ = L.circuit - R = deepcopy(L) + R = QermitPauli(Z_list=[1, 1, 1], X_list=[0, 0, 0], qubit_list=circ.qubits) R.apply_circuit(circ) R_circ = R.circuit @@ -580,9 +580,12 @@ def test_initialisation() -> None: X_list=[0, 0, 0], qubit_list=qubit_list, ) - assert pauli.X_list == {qubit_list[0]: 0, qubit_list[1]: 0, qubit_list[2]: 0} - assert pauli.Z_list == {qubit_list[0]: 0, qubit_list[1]: 0, qubit_list[2]: 1} - assert pauli.phase == 0 + assert pauli.qubit_pauli_tensor == QubitPauliTensor( + string=QubitPauliString( + map={Qubit(0): Pauli.I, Qubit(1): Pauli.I, Qubit(2): Pauli.Z} + ), + coeff=1, + ) def test_identity_clifford() -> None: