From 008eb336da7aaa12a08c71261d9f13cda94b72e2 Mon Sep 17 00:00:00 2001 From: chensgit169 Date: Sat, 23 Dec 2023 17:44:29 +0800 Subject: [PATCH] fix: add symbol setter --- quafu/elements/quantum_gate.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/quafu/elements/quantum_gate.py b/quafu/elements/quantum_gate.py index d816d30..33cecd9 100644 --- a/quafu/elements/quantum_gate.py +++ b/quafu/elements/quantum_gate.py @@ -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]) + ")" @@ -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: