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

Add wire_order option to all circuit drawers to allow defining the order of the wires #8173

Merged
merged 19 commits into from
Jul 12, 2022

Conversation

enavarro51
Copy link
Contributor

Summary

Fixes #8063

Details and comments

This PR adds the wire_order kwarg to circuit_drawer() and QuantumCircuit.draw(). It's entered as a list of bits, e.g.,

qr = QuantumRegister(4, "q")
cr = ClassicalRegister(4, "c")
cr2 = ClassicalRegister(2, "ca")
circuit = QuantumCircuit(qr, cr, cr2)
circuit.h(0)
circuit.h(3)
circuit.x(1)
circuit.x(3).c_if(cr, 10)
circuit.draw('mpl', cregbundle=False, wire_order=[2, 1, 3, 0, 6, 8, 9, 5, 4, 7])

image

The wire_order list must contain an entry for every bit, and the bits are numbered from 0 starting with the first qubit and continuing through the qubits and clbits.

The reverse_bits option works as it did before, but it now uses the same code that wire_order uses.

@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

@coveralls
Copy link

coveralls commented Jun 13, 2022

Pull Request Test Coverage Report for Build 2657707261

  • 114 of 122 (93.44%) changed or added relevant lines in 5 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 84.005%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/latex.py 25 26 96.15%
qiskit/visualization/text.py 44 45 97.78%
qiskit/visualization/matplotlib.py 1 4 25.0%
qiskit/visualization/utils.py 34 37 91.89%
Files with Coverage Reduction New Missed Lines %
qiskit/visualization/matplotlib.py 1 25.62%
Totals Coverage Status
Change from base Build 2656429121: 0.01%
Covered Lines: 55876
Relevant Lines: 66515

💛 - Coveralls

@1ucian0 1ucian0 changed the title Add wire_order option to 3 circuit drawers [unitaryhack] Add wire_order option to 3 circuit drawers Jun 14, 2022
@1ucian0 1ucian0 added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 14, 2022
@1ucian0 1ucian0 self-assigned this Jun 28, 2022
@1ucian0 1ucian0 changed the title [unitaryhack] Add wire_order option to 3 circuit drawers Add wire_order option to 3 circuit drawers Jul 10, 2022
Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

Some comments here and there. Also, considerting extending the tests for checking the warnings and exceptions discussed in #8063 (comment)

qiskit/visualization/utils.py Outdated Show resolved Hide resolved
qiskit/visualization/utils.py Outdated Show resolved Hide resolved
qiskit/visualization/circuit_visualization.py Outdated Show resolved Hide resolved
qiskit/visualization/circuit_visualization.py Outdated Show resolved Hide resolved
@enavarro51
Copy link
Contributor Author

Some comments here and there. Also, considerting extending the tests for checking the warnings and exceptions discussed in #8063 (comment)

Done in a68cef7.

Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

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

Thanks!

@1ucian0 1ucian0 added Changelog: New Feature Include in the "Added" section of the changelog automerge labels Jul 12, 2022
@1ucian0 1ucian0 changed the title Add wire_order option to 3 circuit drawers Add wire_order option to all circuit drawers to allow defining the order of the wires Jul 12, 2022
@mergify mergify bot merged commit 81abc38 into Qiskit:main Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

arbitrary order in circuit drawers
4 participants