Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clifford label on controlled gates #1090

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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