uniqc.visualization.circuit_render package

Submodules

Module contents

Circuit rendering: one entry point, seven output modes.

render() / uniqc.circuit_builder.Circuit.draw() are thin, equivalent wrappers around the same core (per the design-review decision).

Modes: text (self-developed ASCII/Unicode art — no pyqpanda3 needed), svg, png, mpl, latex (quantikz source), html (static, self-contained), interactive (HTML + click-to-inspect).

The core modes (text/svg/latex/html/interactive) are pure-stdlib. png prefers cairosvg and falls back to matplotlib; mpl requires matplotlib.

class uniqc.visualization.circuit_render.TextDrawing[source]

Bases: str

str subclass whose REPL display is the drawing itself (qiskit-style).

uniqc.visualization.circuit_render.render(circuit, mode=None, *, style='quantikz', fold='auto', orientation='h', qubit_order='asc', theme='light', param_mode='pi', show_clbits=False, charset='ascii', scale=100, filename=None)[source]

Render a quantum circuit.

Parameters:
  • circuit – A Circuit, an OriginIR(-ext) or OpenQASM 2.0 string, or a JSON list of gate dicts.

  • mode – None (smart default: terminal→``text``, Jupyter→``svg``), or one of text/svg/png/mpl/latex/html/interactive.

  • style – quantikz (default) | qiskit | modern | print.

  • fold – gates per row — "auto" (terminal width for text, 16 otherwise), an int, or 0 to disable folding.

  • orientation – "h" (time→) or "v" (time↓, graphical modes only).

  • qubit_order – "asc" (q0 on top, default) or "desc".

  • theme – "light" | "dark".

  • param_mode – "pi" (π-fractions, default) | "decimal" | "symbol" | "hidden".

  • show_clbits – draw classical double-line wires (default False).

  • charset – "ascii" (default) | "unicode" for text mode.

  • scale – percent scaling for graphical modes.

  • filename – when given, also write the output to this path.

Returns:

text/svg/latex/html/interactive → str (text returns a TextDrawing whose repr is the art); png → bytes; mpl → matplotlib.figure.Figure.