Skip to content

Commit

Permalink
fix: add same feature to controlled-rotations
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoRobbiati committed Mar 12, 2024
1 parent 185916c commit cf46672
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/qibo/gates/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,12 +1201,27 @@ def __init__(self, q0, q1, theta, trainable=True):
self.parameters = theta
self.unitary = True

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

self.init_args = [q0, q1]
self.init_kwargs = {"theta": theta, "trainable": trainable}

def update_clifford_condition(self, theta):
"""Update Clifford boolean condition according to the given angle ``theta``."""
if isinstance(theta, (float, int)) and (theta % (np.pi / 2)).is_integer():
self.clifford = True
else:
self.clifford = False

@property
def parameters(self):
return self._parameters

@parameters.setter
def parameters(self, value):
self._parameters = value
self.update_clifford_condition(value)

def _dagger(self) -> "Gate":
""""""
q0 = self.control_qubits[0]
Expand Down

0 comments on commit cf46672

Please sign in to comment.