Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend custom multiqubit gates over classical bits for mpl #3062

Merged
merged 5 commits into from
Sep 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions qiskit/visualization/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ def _registers(self, creg, qreg):
def ast(self):
return self._ast

def _custom_multiqubit_gate(self, xy, fc=None, wide=True, text=None,
def _custom_multiqubit_gate(self, xy, cxy=None, fc=None, wide=True, text=None,
subtext=None):
xpos = min([x[0] for x in xy])
ypos = min([y[1] for y in xy])
ypos_max = max([y[1] for y in xy])

if cxy:
ypos = min([y[1] for y in cxy])
if wide:
if subtext:
boxes_length = round(max([len(text), len(subtext)]) / 8) or 1
Expand Down Expand Up @@ -884,7 +887,7 @@ def _draw_ops(self, verbose=False):
self._line(qreg_b, qreg_t, lc=self._style.dispcol['swap'])
# Custom gate
else:
self._custom_multiqubit_gate(q_xy, wide=_iswide,
self._custom_multiqubit_gate(q_xy, c_xy, wide=_iswide,
text=op.name)
#
# draw multi-qubit gates (n=3)
Expand Down Expand Up @@ -917,12 +920,12 @@ def _draw_ops(self, verbose=False):
self._line(qreg_b, qreg_t, lc=self._style.dispcol['multi'])
# custom gate
else:
self._custom_multiqubit_gate(q_xy, wide=_iswide,
self._custom_multiqubit_gate(q_xy, c_xy, wide=_iswide,
text=op.name)

# draw custom multi-qubit gate
elif len(q_xy) > 3:
self._custom_multiqubit_gate(q_xy, wide=_iswide,
self._custom_multiqubit_gate(q_xy, c_xy, wide=_iswide,
text=op.name)
else:
logger.critical('Invalid gate %s', op)
Expand Down