Skip to content

Commit

Permalink
fix: add symbol setter
Browse files Browse the repository at this point in the history
  • Loading branch information
chensgit169 committed Dec 23, 2023
1 parent f8102e9 commit 008eb33
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions quafu/elements/quantum_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ def __init__(self,
):
super().__init__(pos, paras)
self._matrix = matrix
self._symbol = None

@property
def symbol(self):
if self._symbol is not None:
return self._symbol
if self.paras is not None:
if isinstance(self.paras, Iterable):
symbol = "%s(" % self.name + ",".join(["%.3f" % para for para in self.paras]) + ")"
Expand All @@ -42,6 +45,10 @@ def symbol(self):
symbol = "%s" % self.name
return symbol

@symbol.setter
def symbol(self, symbol):
self._symbol = symbol

def update_params(self, paras: Union[float, List[float]]):
"""Update parameters of this gate"""
if paras is None:
Expand Down

0 comments on commit 008eb33

Please sign in to comment.