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

Drawers support for "partial" layout #4795

Merged
merged 9 commits into from
Aug 4, 2020
Merged

Drawers support for "partial" layout #4795

merged 9 commits into from
Aug 4, 2020

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Jul 24, 2020

Fixes #4757

Consider the following example, where the circuit is smaller than the initial_layout length:

from qiskit import QuantumCircuit, transpile
from qiskit.test.mock import FakeTenerife

circuit = QuantumCircuit(3)
circuit.h(1)
transpiled = transpile(circuit, backend=FakeTenerife(),
                             optimization_level=0, initial_layout=list(range(5)),
                             seed_transpiler=0)

This PR allows this situation in all drawers:

transpiled.draw('text')
q_0 -> 0 ────────────
         ┌──────────┐
q_1 -> 1 ┤ U2(0,pi) ├
         └──────────┘
q_2 -> 2 ────────────
                     
       3 ────────────
                     
       4 ────────────
transpiled.draw('mpl')

image

transpiled.draw('latex')

image

Binder link: https://mybinder.org/v2/gh/1ucian0/qiskit-terra/4757?urlpath=apps/test/ipynb/mpl_tester.ipynb

@1ucian0 1ucian0 requested review from maddy-tod, nonhermitian and a team as code owners July 24, 2020 20:00
@1ucian0 1ucian0 added this to the 0.15 milestone Jul 24, 2020
@1ucian0 1ucian0 added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Jul 24, 2020
mtreinish
mtreinish previously approved these changes Aug 4, 2020
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.

LGTM, the only question I had is what if the index isn't in layout at all instead of None. But I guess that edge case isn't realistiic

@mergify mergify bot merged commit 590d645 into Qiskit:master Aug 4, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drawing circuit after transpilation with initial_layout set fails
2 participants