Skip to content

Add barrier label rendering with barrier_label_len to the Rust circuit drawer - #16598

Open
kmbys wants to merge 1 commit into
Qiskit:mainfrom
kmbys:rust-drawer-barrier-label-len
Open

Add barrier label rendering with barrier_label_len to the Rust circuit drawer#16598
kmbys wants to merge 1 commit into
Qiskit:mainfrom
kmbys:rust-drawer-barrier-label-len

Conversation

@kmbys

@kmbys kmbys commented Jul 17, 2026

Copy link
Copy Markdown

Part of #16464 (do not auto-close: this is one item of the tracking issue).

Summary

The Rust circuit drawer previously did not render Barrier labels at all.
This PR ports the barrier label rendering of the Python text drawer,
including the barrier_label_len truncation behavior added in #15776:

  • The label is drawn above the top-most wire of the barrier; the other
    wires keep the plain column, matching the Python text drawer.
  • Labels longer than barrier_label_len characters are truncated at that
    length with a ... suffix.
  • draw_circuit gains a barrier_label_len argument, and the C API's
    QkCircuitDrawerConfig struct gains a barrier_label_len field.
    0 selects the default of 16 characters, so existing struct
    initializers that omit the field keep the previous behavior.

Details and comments

  • OnWireElement::Barrier now carries a reference to its instruction so
    the label is available at render time.
  • The rendering was validated character-for-character against released
    qiskit==2.5.0 output, in both merged and unmerged wire modes.
  • New unit tests cover: default truncation (16), a custom truncation
    length, a barrier whose top-most wire is not the first wire of the
    circuit, and a label of exactly 16 characters (not truncated).
  • A features_c release note is included for the new
    QkCircuitDrawerConfig field.

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description: Claude Fable 5
  • I used the following tool to generate or modify code: Claude Fable 5

…t drawer

Part of Qiskit#16464. Ports the barrier label rendering of the Python text
drawer (including the barrier_label_len truncation added in Qiskit#15776) to
the Rust circuit drawer.

The label is drawn above the top-most wire of the barrier and truncated
to barrier_label_len characters with a '...' suffix when it exceeds that
length, matching the Python text drawer output character-for-character.

The C API's QkCircuitDrawerConfig struct gains a barrier_label_len
field; 0 selects the default of 16 characters, so existing initializers
that omit the field keep the previous default behavior.

Part of Qiskit#16464
@kmbys
kmbys requested a review from a team as a code owner July 17, 2026 05:13
@kmbys
kmbys requested a review from ShellyGarion July 17, 2026 05:13
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jul 17, 2026
@qiskit-bot

Copy link
Copy Markdown
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 following people are relevant to this code:

  • @Qiskit/terra-core

@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PR PRs from contributors that are not 'members' of the Qiskit repo

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants