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 option to user config to control reverse_bits in circuit drawer #9211

Merged
merged 15 commits into from
Jan 18, 2023

Conversation

diemilio
Copy link
Contributor

Summary

Fixes #9150.

Details and comments

This PR adds the option circuit_reverse_bits to the user config file to modify the default behavior of the reverse_bits option in the circuit_drawer. For example, the following configuration in the settings.conf file:

[default]
circuit_drawer = mpl
state_drawer = latex
circuit_reverse_bits = True

the circuit drawer will display a circuit with the most significant bit at the top without explicitly passing the reverse_bits=True option to the draw() method:

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
n = 4
qr = QuantumRegister(n, name='q')
cr = ClassicalRegister(n, name='c')
qc = QuantumCircuit(qr,cr)
qc.h(range(n))
for i in range(n-1,0,-1):
    qc.cx(i,i-1)
qc.barrier()
qc.measure(qr,cr)
qc.draw()

image

@diemilio diemilio requested review from a team and nonhermitian as code owners November 28, 2022 19:49
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Nov 28, 2022
@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:

@1ucian0 1ucian0 self-assigned this Nov 30, 2022
@coveralls
Copy link

coveralls commented Nov 30, 2022

Pull Request Test Coverage Report for Build 3949034173

  • 11 of 11 (100.0%) changed or added relevant lines in 2 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.04%) to 84.873%

Files with Coverage Reduction New Missed Lines %
src/vf2_layout.rs 1 94.74%
src/sabre_swap/layer.rs 2 98.95%
Totals Coverage Status
Change from base Build 3948618953: 0.04%
Covered Lines: 66085
Relevant Lines: 77863

💛 - Coveralls

… file only if `wire_order` option is not passed to drawer

This avoids confusion when user tries to pass `wire_order` to the drawer, but reverse_bits has been set to `True` in the user config file, which will then throw an error.

This means that the `wire_order` option passed to the drawer takes precedence over the `reverse_bits` option set in the user config file.
@mtreinish mtreinish added this to the 0.23.0 milestone Jan 9, 2023
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.

I tweaked the release note slightly and added an extra test that the changes to the user configuration file are correctly loaded up. I hope you don't mind, sorry - normally I'd have asked them in a comment for you to do, but we're getting a little close to the target release of 0.23.0rc1 (my fault for not looking at the PR sooner).

This looks good to me - congratulations on your first code merged to Terra! It'll be released on PyPI as a pre-release hopefully this Thursday and as a full release hopefully a week on Thursday.

@jakelishman jakelishman added Changelog: New Feature Include in the "Added" section of the changelog automerge mod: visualization qiskit.visualization labels Jan 17, 2023
@diemilio
Copy link
Contributor Author

Thank you @jakelishman!

@jakelishman
Copy link
Member

No worries! There's no need for you do anything more here, by the way - the bot will take care of merging. We're just having minor problems with our CI at the moment, which should be cleared out in a couple of hours' time.

@Mergifyio requeue

@jakelishman
Copy link
Member

@Mergifyio requeue

@mergify
Copy link
Contributor

mergify bot commented Jan 18, 2023

requeue

✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically

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 mod: visualization qiskit.visualization
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add option in user config file to control reverse_bits in circuit_drawer
6 participants