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

Fix top-level switch statements in QuantumCircuit.compose #10164

Merged
merged 3 commits into from
May 30, 2023

Conversation

jakelishman
Copy link
Member

Summary

The register-mapping code was not being applied to SwitchCaseOp.target in the same way that it is for conditions. This commit does not change any behaviour about recursing into nested control-flow blocks, which still likely have problems with composition.

Details and comments

Fix #10108, at least as far as the top-level issue that's being reported there. See that issue for a further discussion of other problems that stem from the root of that issue.

The register-mapping code was not being applied to `SwitchCaseOp.target`
in the same way that it is for conditions.  This commit does not change
any behaviour about recursing into _nested_ control-flow blocks, which
still likely have problems with composition.
@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 labels May 25, 2023
@jakelishman jakelishman requested a review from a team as a code owner May 25, 2023 12:56
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5080209383

  • 18 of 19 (94.74%) changed or added relevant lines in 1 file are covered.
  • 23 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.01%) to 85.926%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/quantumcircuit.py 18 19 94.74%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 5 91.14%
crates/qasm2/src/parse.rs 18 96.65%
Totals Coverage Status
Change from base Build 5073178665: -0.01%
Covered Lines: 71279
Relevant Lines: 82954

💛 - Coveralls

qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

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

LGTM!

@kevinhartman kevinhartman added this pull request to the merge queue May 30, 2023
Merged via the queue into Qiskit:main with commit 76850e1 May 30, 2023
mergify bot pushed a commit that referenced this pull request May 30, 2023
* Fix top-level `switch` statements in `QuantumCircuit.compose`

The register-mapping code was not being applied to `SwitchCaseOp.target`
in the same way that it is for conditions.  This commit does not change
any behaviour about recursing into _nested_ control-flow blocks, which
still likely have problems with composition.

* Apply suggestions from review

(cherry picked from commit 76850e1)
jakelishman added a commit that referenced this pull request May 30, 2023
#10180)

* Fix top-level `switch` statements in `QuantumCircuit.compose`

The register-mapping code was not being applied to `SwitchCaseOp.target`
in the same way that it is for conditions.  This commit does not change
any behaviour about recursing into _nested_ control-flow blocks, which
still likely have problems with composition.

* Apply suggestions from review

(cherry picked from commit 76850e1)

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
@jakelishman jakelishman deleted the compose-controlflow branch June 20, 2023 11:45
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 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.

Composing circuit with a switch statement causes a bug in the QASM3 exporter
4 participants