Skip to content

Pretty print for Statevec #100

@king-p3nguin

Description

@king-p3nguin

Edit (2025/12/08): First part of this issue subsumed in #386 for UnitaryDesign2026
Edit (2026/03/11): .to_dict method introduced in #457

The following methods may improve the utility of Statevec:

  • .draw(): show state vector in latex format (in jupyter notebook) or text (in command line)
    • add format to parameter ("latex" or "text")

Edit (2026/04/14): Some guidelines about what we expect for this issue:

  • It is definitely worth seeing what other tools, such as Qiskit, do for inspiration, but we would prefer not to add another dependency just for pretty-printing, so the code should be self-contained.
  • We would like common values to be rendered nicely: that includes fractions (0.25 should be printed as $\frac 1 4$), square roots (0.70710678 should be printed as $\frac {\sqrt 2} 2$) and exponentials (0.5 + 0.8660254j should be printed as $\mathrm e^{\mathrm i \frac \pi 3}$.
  • The printing logic should be implemented in pretty_print.py and use the OutputFormat enum.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions