-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1370 from sergiomtzlosa/matplotlib-circuit-drawer
Matplotlib circuit drawer
- Loading branch information
Showing
7 changed files
with
1,387 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
470 changes: 470 additions & 0 deletions
470
examples/circuit-draw-mpl/qibo-draw-circuit-matplotlib.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from qibo.ui.mpldrawer import plot_circuit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from qibo.gates.abstract import Gate | ||
|
||
|
||
class FusedStartGateBarrier(Gate): | ||
""" | ||
:class:`qibo.ui.drawer_utils.FusedStartGateBarrier` gives room to fused group of gates. | ||
Inherit from ``qibo.gates.abstract.Gate``. A special gate barrier gate to pin the starting point of fused gates. | ||
""" | ||
|
||
def __init__(self, q_ctrl, q_trgt, nfused, equal_qbits=False): | ||
|
||
super().__init__() | ||
self.name = ( | ||
"FusedStartGateBarrier" | ||
+ str(nfused) | ||
+ ("" if not equal_qbits else "@EQUAL") | ||
) | ||
self.draw_label = "" | ||
self.control_qubits = (q_ctrl,) | ||
self.target_qubits = (q_trgt,) if q_ctrl != q_trgt else () | ||
self.init_args = [q_trgt, q_ctrl] if q_ctrl != q_trgt else [q_ctrl] | ||
self.unitary = False | ||
self.is_controlled_by = False | ||
self.nfused = nfused | ||
|
||
|
||
class FusedEndGateBarrier(Gate): | ||
""" | ||
:class:`qibo.ui.drawer_utils.FusedEndGateBarrier` gives room to fused group of gates. | ||
Inherit from ``qibo.gates.abstract.Gate``. A special gate barrier gate to pin the ending point of fused gates. | ||
""" | ||
|
||
def __init__(self, q_ctrl, q_trgt): | ||
|
||
super().__init__() | ||
self.name = "FusedEndGateBarrier" | ||
self.draw_label = "" | ||
self.control_qubits = (q_ctrl,) | ||
self.target_qubits = (q_trgt,) if q_ctrl != q_trgt else () | ||
self.init_args = [q_trgt, q_ctrl] if q_ctrl != q_trgt else [q_ctrl] | ||
self.unitary = False | ||
self.is_controlled_by = False |
Oops, something went wrong.