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 edge coloring bug in plot_coupling_map #12369

Merged
merged 2 commits into from
May 9, 2024

Conversation

kevinsung
Copy link
Contributor

Summary

Fixes #12354 .

Details and comments

The conversion to an undirected graph changes the edge ordering, causing it not to match the color ordering. This change uses a dictionary to recover the correct ordering.

@kevinsung kevinsung requested review from nonhermitian and a team as code owners May 8, 2024 11:15
@qiskit-bot
Copy link
Collaborator

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

@kevinsung kevinsung added the Changelog: Bugfix Include in the "Fixed" section of the changelog label May 8, 2024
@kevinsung kevinsung added this to the 1.1.0 milestone May 8, 2024
@coveralls
Copy link

coveralls commented May 8, 2024

Pull Request Test Coverage Report for Build 9021050859

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 2 (0.0%) changed or added relevant lines in 1 file are covered.
  • 10 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.01%) to 89.649%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/gate_map.py 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.03%
qiskit/visualization/gate_map.py 1 6.98%
crates/qasm2/src/lex.rs 2 93.13%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 3 88.02%
qiskit/quantum_info/states/stabilizerstate.py 3 93.49%
Totals Coverage Status
Change from base Build 8999743027: 0.01%
Covered Lines: 62211
Relevant Lines: 69394

💛 - Coveralls

@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label May 8, 2024
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 looks good to me. It relies on the internal implementation detail about how the to_undirected method works in rustworkx (internally iterates over the edges in id order). But while undocumented it is unlikely to ever change so it's fine. The only thing is could you add a release note to document this fix?

@kevinsung
Copy link
Contributor Author

This looks good to me. It relies on the internal implementation detail about how the to_undirected method works in rustworkx (internally iterates over the edges in id order). But while undocumented it is unlikely to ever change so it's fine. The only thing is could you add a release note to document this fix?

Sorry, I don't understand. I think the iteration order doesn't matter because line_color_map is a dictionary.

@mtreinish
Copy link
Member

Sorry that was mistake I misread the edge_list() method as edge_indices() somehow and thought you were just doing a mapping of explicit index to the index in a list. Which would work (and actually would be slightly faster) but would depend on the internal behavior. What you have here is more robust and a better approach.

@mtreinish mtreinish enabled auto-merge May 9, 2024 17:32
@mtreinish mtreinish added this pull request to the merge queue May 9, 2024
Merged via the queue into Qiskit:main with commit 24f1436 May 9, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request May 9, 2024
* fix edge coloring bug in plot circuit layout

* add release note

(cherry picked from commit 24f1436)
@kevinsung kevinsung deleted the plot-circuit-layout branch May 9, 2024 22:19
github-merge-queue bot pushed a commit that referenced this pull request May 10, 2024
* fix edge coloring bug in plot circuit layout

* add release note

(cherry picked from commit 24f1436)

Co-authored-by: Kevin J. Sung <[email protected]>
ElePT pushed a commit to ElePT/qiskit that referenced this pull request May 31, 2024
* fix edge coloring bug in plot circuit layout

* add release note
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.

plot_circuit_layout colors edges incorrectly
4 participants