Skip to content

Commit

Permalink
Corrected tests compression and refactored for Qiskit#6370
Browse files Browse the repository at this point in the history
  • Loading branch information
TharrmashasthaPV committed Jul 13, 2021
1 parent 54387af commit 6108eb8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions qiskit/visualization/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,8 +1390,8 @@ def set_cl_multibox(self, creg, val, top_connect="┴"):
else:
if isinstance(creg, Clbit):
clbit = [creg]
label_bool = "= T" if val is True else "= F"
self._set_multibox(label_bool, clbits=clbit, top_connect=top_connect)
cond_bin = "1" if val is True else "0"
self.set_cond_bullets(cond_bin, clbit)
else:
clbit = [
bit for bit in self.clbits if self._clbit_locations[bit]["register"] == creg
Expand Down
26 changes: 15 additions & 11 deletions test/python/visualization/test_circuit_text_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2920,15 +2920,15 @@ def test_text_bit_conditional(self):

expected = "\n".join(
[
" ┌───┐ ",
"qr_0: |0>┤ H ├────────",
" └─╥─┘ ┌───┐ ",
"qr_1: |0>──╫────┤ H ├",
" ┌──╨──┐ └─╥─┘ ",
" cr_0: 0 ╡ = T ╞═══╬═══",
" └─────┘┌──╨──┐",
" cr_1: 0 ═══════╡ = F ╞",
" └─────┘",
" ┌───┐ ",
"qr_0: |0>┤ H ├─────",
" └─╥─┘┌───┐",
"qr_1: |0>──╫──┤ H ├",
" └─╥─┘",
" cr_0: 0 ══■════╬══",
" =1 ║ ",
" cr_1: 0 ═══════o══",
" =0 ",
]
)

Expand All @@ -2949,13 +2949,17 @@ def test_text_bit_conditional_cregbundle(self):
"qr_0: |0>───┤ H ├────────────────",
" └─╥─┘ ┌───┐ ",
"qr_1: |0>─────╫─────────┤ H ├────",
" ┌────╨─────┐┌──┴─╨─┴───┐",
" ║ └─╥─┘ ",
" ┌────╨─────┐┌────╨─────┐",
" cr: 0 2/╡ cr_0 = T ╞╡ cr_1 = F ╞",
" └──────────┘└──────────┘",
]
)

self.assertEqual(str(_text_circuit_drawer(circuit, cregbundle=True)), expected)
self.assertEqual(
str(_text_circuit_drawer(circuit, cregbundle=True, vertical_compression="medium")),
expected,
)

def test_text_conditional_reverse_bits_1(self):
"""Classical condition on 2q2c circuit with cregbundle=False and reverse bits"""
Expand Down

0 comments on commit 6108eb8

Please sign in to comment.