Skip to content

Commit

Permalink
fix: update gate.clifford value in rotations given a new theta
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoRobbiati committed Mar 12, 2024
1 parent a603ddd commit 185916c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/qibo/gates/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,28 @@ def __init__(self, q, theta, trainable=True):
if isinstance(theta, Parameter):
theta = theta()

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

self.parameters = theta
self._parameters = theta
self.init_args = [q]
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":
""""""
return self.__class__(
Expand Down

0 comments on commit 185916c

Please sign in to comment.