diff --git a/QElephant/Circuit.py b/QElephant/Circuit.py index 7c821b0..39ed823 100644 --- a/QElephant/Circuit.py +++ b/QElephant/Circuit.py @@ -23,8 +23,8 @@ class Circuit: def __line(self, A, B) -> None: plt.plot([A[0], B[0]], [A[1], B[1]], color='Black') - def __circle(self, x: float, y: float, radius: float) -> None: - circ = Circle((x, y), radius, fill=True, color='Black') + def __circle(self, x: float, y: float, radius: float, fill=True) -> None: + circ = Circle((x, y), radius, fill=fill, color='Black') plt.gca().add_patch(circ) def draw(self) -> None: @@ -40,15 +40,20 @@ class Circuit: self.__line((i+1.25, q_i), (i+1.5, q_i)) if q_i == index: - self.__rect(i+1, q_i, txt, n) - for neig in neigbhor: - self.__circle(i+1, neig, 0.05) - if neig > q_i: - self.__line((i+1, q_i+0.25), (i+1, neig)) - elif neig < q_i: - self.__line((i+1, q_i-0.25), (i+1, neig)) - else: - raise ValueError("Cannot apply gate twice on the same QuBit") + if txt == "X": + self.__circle(i+1, q_i, 0.25, False) + self.__line((i+0.75, q_i), (i+1.25, q_i)) + self.__line((i+1, q_i-0.25), (i+1, q_i+0.25)) + else: + self.__rect(i+1, q_i, txt, n) + for neig in neigbhor: + self.__circle(i+1, neig, 0.05) + if neig > q_i: + self.__line((i+1, q_i+0.25), (i+1, neig)) + elif neig < q_i: + self.__line((i+1, q_i-0.25), (i+1, neig)) + else: + raise ValueError("Cannot apply gate twice on the same QuBit") else: self.__line((i+0.75, q_i), (i+1.25, q_i)) i += 1 diff --git a/QElephant/QuBit.py b/QElephant/QuBit.py index d779582..2931f88 100644 --- a/QElephant/QuBit.py +++ b/QElephant/QuBit.py @@ -441,7 +441,7 @@ def CX(q: MuBit, n1: int, n2: int) -> None: q._MuBit__mapply(Matrix.CX(), n-2) SWAP(q, n-2, n1) SWAP(q, n-1, n2) - q._MuBit__emit("CX", n1, [n2]) + q._MuBit__emit("X", n1, [n2]) def CY(q: MuBit, n1: int, n2: int) -> None: if type(q) is not MuBit: @@ -463,7 +463,7 @@ def CY(q: MuBit, n1: int, n2: int) -> None: q._MuBit__mapply(Matrix.CY(), n-2) SWAP(q, n-2, n1) SWAP(q, n-1, n2) - q._MuBit__emit("CY", n1, [n2]) + q._MuBit__emit("Y", n1, [n2]) def CZ(q: MuBit, n1: int, n2: int) -> None: if type(q) is not MuBit: @@ -485,7 +485,7 @@ def CZ(q: MuBit, n1: int, n2: int) -> None: q._MuBit__mapply(Matrix.CZ(), n-2) SWAP(q, n-2, n1) SWAP(q, n-1, n2) - q._MuBit__emit("CZ", n1, [n2]) + q._MuBit__emit("Z", n1, [n2]) def SWAP(q: MuBit, n1: int, n2: int) -> None: if type(q) is not MuBit: @@ -542,4 +542,4 @@ def Cu(q: MuBit, u: list[list[complex]], n1: int, n2: int) -> None: q._MuBit__mapply(Matrix.Cu(u), n-2) SWAP(q, n-2, n1) SWAP(q, n-1, n2) - q._MuBit__emit("Cu", n1, [n2]) \ No newline at end of file + q._MuBit__emit("U", n1, [n2]) \ No newline at end of file