Skip to content

Commit

Permalink
Reformat pauliopt
Browse files Browse the repository at this point in the history
  • Loading branch information
daehiff committed Jul 28, 2024
1 parent bd704c4 commit bdf8627
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 5 additions & 5 deletions pauliopt/clifford/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def from_tableau(tableau, signs):
"""
n_qubits = tableau.shape[0] // 2
if not (
tableau.shape == (2 * n_qubits, 2 * n_qubits)
and signs.shape == (2 * n_qubits,)
tableau.shape == (2 * n_qubits, 2 * n_qubits)
and signs.shape == (2 * n_qubits,)
):
raise ValueError(
"Tableau and signs must have shape "
Expand Down Expand Up @@ -198,8 +198,8 @@ def z_out(self, row, col):
col (int): Column index.
"""
return (
self.tableau[row + self.n_qubits, col]
+ 2 * self.tableau[row + self.n_qubits, col + self.n_qubits]
self.tableau[row + self.n_qubits, col]
+ 2 * self.tableau[row + self.n_qubits, col + self.n_qubits]
)

def _xor_row(self, i, j):
Expand Down Expand Up @@ -363,7 +363,7 @@ def apply(self, other: "CliffordTableau"):
for k in range(2 * self.n_qubits):
row2 = other.tableau[k]
x2 = other.tableau[k, : self.n_qubits]
z2 = other.tableau[k, self.n_qubits:]
z2 = other.tableau[k, self.n_qubits :]

# Adding a factor of i for each Y in the image of an operator under the
# first operation, since Y=iXZ
Expand Down
18 changes: 13 additions & 5 deletions pauliopt/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ def propagate_pauli(self, gadget: "pauliopt.pauli.pauli_gadget.PauliGadget"):
gadget.angle *= phase_change
elif gate.name == "CX":
assert isinstance(gate, TwoQubitClifford)
p_string = gadget.paulis[gate.control].value + gadget.paulis[gate.target].value
p_string = (
gadget.paulis[gate.control].value + gadget.paulis[gate.target].value
)
p_c, p_t, phase_change = PROPAGATION_CX[p_string]
gadget.paulis[gate.control] = p_c
gadget.paulis[gate.target] = p_t
Expand Down Expand Up @@ -366,9 +368,11 @@ def inverse(self):
return Y(*self.qubits)

def get_h_s_cx_decomposition(self) -> List[Union["H", "S", "CX"]]:
return (Sdg(*self.qubits).get_h_s_cx_decomposition()
+ X(*self.qubits).get_h_s_cx_decomposition()
+ S(*self.qubits).get_h_s_cx_decomposition())
return (
Sdg(*self.qubits).get_h_s_cx_decomposition()
+ X(*self.qubits).get_h_s_cx_decomposition()
+ S(*self.qubits).get_h_s_cx_decomposition()
)


class S(SingleQubitClifford):
Expand Down Expand Up @@ -460,7 +464,11 @@ def inverse(self):
return V(*self.qubits)

def get_h_s_cx_decomposition(self) -> List[Union["H", "S", "CX"]]:
return [H(*self.qubits)] + Sdg(*self.qubits).get_h_s_cx_decomposition() + [H(*self.qubits)]
return (
[H(*self.qubits)]
+ Sdg(*self.qubits).get_h_s_cx_decomposition()
+ [H(*self.qubits)]
)


class T(Gate):
Expand Down

0 comments on commit bdf8627

Please sign in to comment.