Skip to content

Commit

Permalink
fixed custom wire labels
Browse files Browse the repository at this point in the history
  • Loading branch information
gadhvirushiraj committed Aug 21, 2024
1 parent aad7942 commit 2083e24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doc/source/qip-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ QuTiP-QIP offers three distinct methods for visualizing quantum circuits. Below

* - ``gate_pad : int``
- The padding between the gate and the gate label.
* - ``wire_label : Optional[List]``
- The labels of the wires.
* - ``align_layer : bool``
- Align the layers of the gates across different wires.
* - ``end_wire_ext : int``
Expand Down
12 changes: 9 additions & 3 deletions src/qutip_qip/circuit/text_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ def _add_wire_labels(self):
Add wire labels to the circuit
"""

default_labels = [f"q{i}" for i in range(self._qwires)] + [
f"c{i}" for i in range(self._cwires)
]
if self.style.wire_label is None:
default_labels = [f"q{i}" for i in range(self._qwires)] + [
f"c{i}" for i in range(self._cwires)
]
else:
default_labels = (
self.style.wire_label[self._cwires :]
+ self.style.wire_label[: self._cwires]
)

max_label_len = max([len(label) for label in default_labels])
for i, label in enumerate(default_labels):
Expand Down

0 comments on commit 2083e24

Please sign in to comment.