Skip to content

Commit

Permalink
Merge pull request #1090 from qiboteam/clifford_label
Browse files Browse the repository at this point in the history
Fix ``Clifford`` label on controlled gates
  • Loading branch information
renatomello authored Nov 16, 2023
2 parents ad2fd18 + 0b0e336 commit 8194acb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/qibo/gates/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,6 @@ def __init__(self, q0, q1):
self.control_qubits = (q0,)
self.target_qubits = (q1,)
self.init_args = [q0, q1]
self.clifford = True
self.unitary = True

@property
Expand Down Expand Up @@ -1082,7 +1081,6 @@ def __init__(self, q0, q1):
self.control_qubits = (q0,)
self.target_qubits = (q1,)
self.init_args = [q0, q1]
self.clifford = True
self.unitary = True

@property
Expand Down Expand Up @@ -1119,7 +1117,7 @@ def __init__(self, q0, q1, theta, trainable=True):
self.parameters = theta
self.unitary = True

if isinstance(theta, (float, int)) and (theta % (np.pi / 2)).is_integer():
if isinstance(theta, (float, int)) and (theta % np.pi).is_integer():
self.clifford = True

self.init_args = [q0, q1]
Expand Down Expand Up @@ -2086,7 +2084,6 @@ def __init__(self, q0, q1, q2):
self.control_qubits = (q0, q1)
self.target_qubits = (q2,)
self.init_args = [q0, q1, q2]
self.clifford = True
self.unitary = True

@property
Expand Down
8 changes: 4 additions & 4 deletions tests/test_gates_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def test_csx(backend):
backend.assert_allclose(final_state_decompose, target_state)

assert gates.CSX(0, 1).qasm_label == "csx"
assert gates.CSX(0, 1).clifford
assert not gates.CSX(0, 1).clifford
assert gates.CSX(0, 1).unitary


Expand Down Expand Up @@ -590,7 +590,7 @@ def test_csxdg(backend):
backend.assert_allclose(final_state_decompose, target_state)

assert gates.CSXDG(0, 1).qasm_label == "csxdg"
assert gates.CSXDG(0, 1).clifford
assert not gates.CSXDG(0, 1).clifford
assert gates.CSXDG(0, 1).unitary


Expand Down Expand Up @@ -624,7 +624,7 @@ def test_cun(backend, name, params):

if name in ["CRX", "CRY", "CRZ"]:
theta = params["theta"]
if (theta % (np.pi / 2)).is_integer():
if (theta % np.pi).is_integer():
assert gate.clifford
else:
assert not gate.clifford
Expand Down Expand Up @@ -1098,7 +1098,7 @@ def test_toffoli(backend, applyx):
backend.assert_allclose(final_state, target_state)

assert gatelist[-1].qasm_label == "ccx"
assert gates.TOFFOLI(0, 1, 2).clifford
assert not gates.TOFFOLI(0, 1, 2).clifford
assert gates.TOFFOLI(0, 1, 2).unitary


Expand Down

0 comments on commit 8194acb

Please sign in to comment.