Skip to content

Commit

Permalink
Correct wrong phase
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-mills-cqc committed Dec 11, 2024
1 parent f44846e commit ef4f65b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion qermit/coherent_pauli_checks/pauli_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 6 additions & 6 deletions qermit/noise_model/qermit_pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down
11 changes: 7 additions & 4 deletions tests/noise_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit ef4f65b

Please sign in to comment.