Skip to content

Commit

Permalink
fixing globephase rendering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
gadhvirushiraj committed Nov 5, 2024
1 parent 1a4716f commit e79f148
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/qutip_qip/circuit/mat_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,14 @@ def _draw_multiq_gate(self, gate: Gate, layer: int) -> None:

else:

adj_targets = [i + self._cwires for i in sorted(gate.targets)]
adj_targets = [
i + self._cwires
for i in sorted(
gate.targets
if gate.targets is not None
else list(range(self._qwires)) # adaptation for globalphase
)
]
text_width = self._get_text_width(
self.text,
self.fontsize,
Expand Down Expand Up @@ -687,7 +694,7 @@ def _draw_multiq_gate(self, gate: Gate, layer: int) -> None:
zorder=self._zorder["gate"],
)

if len(gate.targets) > 1:
if gate.targets is not None and len(gate.targets) > 1:
for i in range(len(gate.targets)):
connector_l = Circle(
(
Expand Down Expand Up @@ -845,10 +852,16 @@ def canvas_plot(self) -> None:

# multi-qubit gate
if (
len(gate.targets) > 1
gate.targets is None
or len(gate.targets) > 1
or getattr(gate, "controls", False) is not None
):
self.merged_wires = gate.targets.copy()
# If targets=None, it implies globalphase. Adaptation for the renderer: targets=all-qubits.
self.merged_wires = (
gate.targets.copy()
if gate.targets is not None
else list(range(self._qwires))
)
if gate.controls is not None:
self.merged_wires += gate.controls.copy()
self.merged_wires.sort()
Expand Down

0 comments on commit e79f148

Please sign in to comment.