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

Infer cregbundle for all drawers #9133

Merged
merged 7 commits into from
Nov 23, 2022

Conversation

jakelishman
Copy link
Member

Summary

This swaps the default behaviour for the cregbundle to always bundle if possible, but not to emit a warning if the bundles are expanded and no concrete value was given for the parameter. Previously, this sort of logic was only done for the text drawer.

Details and comments

Fix #9129. This was previously done for the text drawer in #8689, but this PR makes it true for all the existing drawers.

This swaps the default behaviour for the `cregbundle` to always bundle
if possible, but not to emit a warning if the bundles are expanded and
no concrete value was given for the parameter.  Previously, this sort of
logic was only done for the text drawer.
@jakelishman jakelishman added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: visualization qiskit.visualization labels Nov 15, 2022
@jakelishman jakelishman requested review from a team and nonhermitian as code owners November 15, 2022 14:10
@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:

Many tests use the internal `_text_circuit_drawer` function, which has
different defaults to the standard `circuit_drawer` function.  Since
this commit chain made this default the same all the way through the
tree, several tests changed their output, or needed the keyword
arguments updating.
@jakelishman
Copy link
Member Author

In 825c5cf, I saw a couple of tests that were testing incorrect behaviour. I made issue #9173 about it, and here I've updated the relevant tests to have unittest.expectedFailure and the correct assertions.

@jakelishman jakelishman added this to the 0.22.3 milestone Nov 22, 2022
@coveralls
Copy link

coveralls commented Nov 22, 2022

Pull Request Test Coverage Report for Build 3533453309

  • 26 of 28 (92.86%) changed or added relevant lines in 4 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.3%) to 84.514%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/circuit/latex.py 7 8 87.5%
qiskit/visualization/circuit/matplotlib.py 7 8 87.5%
Files with Coverage Reduction New Missed Lines %
src/sabre_swap/layer.rs 1 98.43%
src/vf2_layout.rs 3 94.74%
Totals Coverage Status
Change from base Build 3532114398: 0.3%
Covered Lines: 62783
Relevant Lines: 74287

💛 - Coveralls

@jakelishman
Copy link
Member Author

I reverted 825c5cf, since I realised that it was a bad idea to do that in an unrelated PR. #9173 is the correct tracker for that.

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.

I'm good with this change, but since it's technically a behavior change for the text drawer I'm wondering if we want to actually backport this for 0.22.3. I'm leaning towards yes because I think it'll be good to fix the warning for the other drawers and also I'm not sure the default formatting for the text drawer is really significant api contract as long as it represents the circuit accurately.

@jakelishman
Copy link
Member Author

The text drawer doesn't actually change public behaviour here. The tests changed because they use a private internal function whose cregbundle default had got out-of-sync with the default set in the public entry point, but the tests use the internal function (not certain why). This change propagates the new default all the way through the stack, which is what caused the tests to actually change.

Nothing actually changes public behaviour here - various internal-only functions had cregbundle=False defaults, but those were always overridden by public API calls, with the end result being everything defaulted to True (or the inferring behaviour, in the case of text). This PR just sets everything to default to the infer behaviour, which doesn't change anything about the visual output from using a public API point without specifying cregbundle, it just suppresses the warnings from mpl and latex if it has to set cregbundle=False.

@mergify mergify bot merged commit 35733a5 into Qiskit:main Nov 23, 2022
mergify bot pushed a commit that referenced this pull request Nov 23, 2022
* Infer `cregbundle` for all drawers

This swaps the default behaviour for the `cregbundle` to always bundle
if possible, but not to emit a warning if the bundles are expanded and
no concrete value was given for the parameter.  Previously, this sort of
logic was only done for the text drawer.

* Update tests for new default behaviour

Many tests use the internal `_text_circuit_drawer` function, which has
different defaults to the standard `circuit_drawer` function.  Since
this commit chain made this default the same all the way through the
tree, several tests changed their output, or needed the keyword
arguments updating.

* Fix missing warning test

* Revert unrelated expectedFailure changes

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 35733a5)
mergify bot added a commit that referenced this pull request Nov 23, 2022
* Infer `cregbundle` for all drawers

This swaps the default behaviour for the `cregbundle` to always bundle
if possible, but not to emit a warning if the bundles are expanded and
no concrete value was given for the parameter.  Previously, this sort of
logic was only done for the text drawer.

* Update tests for new default behaviour

Many tests use the internal `_text_circuit_drawer` function, which has
different defaults to the standard `circuit_drawer` function.  Since
this commit chain made this default the same all the way through the
tree, several tests changed their output, or needed the keyword
arguments updating.

* Fix missing warning test

* Revert unrelated expectedFailure changes

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 35733a5)

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Cryoris pushed a commit to Cryoris/qiskit-terra that referenced this pull request Jan 12, 2023
* Infer `cregbundle` for all drawers

This swaps the default behaviour for the `cregbundle` to always bundle
if possible, but not to emit a warning if the bundles are expanded and
no concrete value was given for the parameter.  Previously, this sort of
logic was only done for the text drawer.

* Update tests for new default behaviour

Many tests use the internal `_text_circuit_drawer` function, which has
different defaults to the standard `circuit_drawer` function.  Since
this commit chain made this default the same all the way through the
tree, several tests changed their output, or needed the keyword
arguments updating.

* Fix missing warning test

* Revert unrelated expectedFailure changes

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@jakelishman jakelishman deleted the fix/cregbundle-warning branch January 16, 2023 12:22
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.

Simple dynamic circuits raise RuntimeWarning
4 participants