Skip to content

Fix display of Box End after transpile in text drawer #14278

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

Merged
merged 27 commits into from
May 2, 2025

Conversation

enavarro51
Copy link
Contributor

Summary

Fix #14271

Details and comments

This fixes a problem when the text drawer incorrectly displayed the End of a Box after a transpile.

qc = QuantumCircuit(4)
with qc.box():
    qc.cx(0,1)
    qc.cx(0,3)

qc_ = transpile(qc, initial_layout=[2,3,1,0])

print(qc_.draw(idle_wires=True))

Now produces

         ┌───────      ┌───┐ ───────┐
q_3 -> 0 ┤        ─────┤ X ├        ├─
         │             └─┬─┘        │
q_2 -> 1 ┤        ───────┼──        ├─
         │ Box-0         │    End-0 │
q_0 -> 2 ┤        ──■────■──        ├─
         │        ┌─┴─┐             │
q_1 -> 3 ┤        ┤ X ├─────        ├─
         └─────── └───┘      ───────┘

@enavarro51 enavarro51 requested review from nonhermitian and a team as code owners May 1, 2025 15:15
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

mtreinish
mtreinish previously approved these changes May 1, 2025
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lgtm, thanks for fixing this

@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label May 1, 2025
@mtreinish mtreinish added Changelog: Bugfix Include in the "Fixed" section of the changelog mod: visualization qiskit.visualization labels May 1, 2025
@mtreinish mtreinish added this to the 2.0.1 milestone May 1, 2025
@coveralls
Copy link

coveralls commented May 1, 2025

Pull Request Test Coverage Report for Build 14799279952

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 9 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.01%) to 87.915%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
crates/qasm2/src/lex.rs 2 92.98%
crates/qasm2/src/parse.rs 6 97.61%
Totals Coverage Status
Change from base Build 14753521295: 0.01%
Covered Lines: 74567
Relevant Lines: 84817

💛 - Coveralls

jakelishman
jakelishman previously approved these changes May 2, 2025
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Ed - I just hit this exact same bug with other control-flow constructs while writing a new version of SabreSwap too, and it was making it hard to debug!

@jakelishman jakelishman enabled auto-merge May 2, 2025 16:32
@enavarro51
Copy link
Contributor Author

Always happy to help - for the easy ones...

@jakelishman jakelishman added this pull request to the merge queue May 2, 2025
Merged via the queue into Qiskit:main with commit 3e96ade May 2, 2025
24 checks passed
mergify bot pushed a commit that referenced this pull request May 2, 2025
* Fix typing-extensions

* Fix text drawer flow end display

* Lint

* Add reno

---------

Co-authored-by: Jake Lishman <[email protected]>
(cherry picked from commit 3e96ade)
github-merge-queue bot pushed a commit that referenced this pull request May 2, 2025
* Fix typing-extensions

* Fix text drawer flow end display

* Lint

* Add reno

---------

Co-authored-by: Jake Lishman <[email protected]>
(cherry picked from commit 3e96ade)

Co-authored-by: Edwin Navarro <[email protected]>
@ElePT
Copy link
Contributor

ElePT commented May 8, 2025

@Mergifyio backport stable/1.4

Copy link
Contributor

mergify bot commented May 8, 2025

backport stable/1.4

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request May 8, 2025
* Fix typing-extensions

* Fix text drawer flow end display

* Lint

* Add reno

---------

Co-authored-by: Jake Lishman <[email protected]>
(cherry picked from commit 3e96ade)

# Conflicts:
#	test/python/visualization/test_circuit_text_drawer.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: visualization qiskit.visualization stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

box does not draw correctly after transpile
6 participants