Skip to content

box does not draw correctly after transpile #14271

@aeddins-ibm

Description

@aeddins-ibm

Environment

  • Qiskit version: 2.0.0
  • Python version: 3.11
  • Operating system: mac

What is happening?

If we add a box to a circuit, then apply a layout to the circuit (via transpile), the new circuit may not draw the right end of the box correctly (with the default, text-based draw output).

How can we reproduce the issue?

qc = QuantumCircuit(4)
with qc.box():
    qc.cx(0,1)
    qc.cx(0,3)

print('before transpile:')
print(qc.draw())

qc_ = transpile(qc, initial_layout=[2,3,1,0])
print('after transpile:')
print(qc_.draw())

print('after transpile, showing idles:')
print(qc_.draw(idle_wires=True))
Image

What should happen?

The right end of the box should be rendered correctly, as roughly shown below.

This next thing should probably be a separate feature request, but since we're on the topic of box drawing: can/should we number the pinout of the box? I did this in pink for visibility below. This would match the behavior when drawing an appended subcircuit. The pinout might seem unimportant since the box contents are already drawn explicitly, but it could still be helpful when reasoning about annotations or other metadata associated with the box.

Image

Any suggestions?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions