Diagrams#
This module provides classes for the creation of diagrams of quantum states, gates, and circuits.
It is not intended to be used directly by the user.
from qhronology.utilities import diagrams
Classes for the creation of diagrams of quantum states, gates, and circuits. Not intended to be used directly by the user.
- class DiagramCell(
- *args,
- family: str | None = None,
- connections: dict[str, str] | None = None,
- label: str | None = None,
- quantikz_arguments: dict[str, str] | None = None,
- **kwargs,
A class for visualizing individual “cells” (the smallest indivisible units) of quantum circuit diagrams and storing their metadata.
- class DiagramColumn(
- *args,
- cells: list[DiagramCell],
- section: str | None = None,
- **kwargs,
A class for assembling a collection of
DiagramCellinstances into a column.
- class DiagramCircuit(
- *args,
- columns: list,
- **kwargs,
A class for assembling
DiagramColumninstances together into a grid.
- class VisualizationMixin[source]#
A mixin for endowing classes derived from the base class
QuantumObjectthe ability to be visualized as quantum circuit diagram elements.- diagram(
- pad: tuple[int, int] | None = None,
- sep: tuple[int, int] | None = None,
- style: str | None = None,
- return_string: bool | None = None,
Print or return a circuit diagram of the quantum object as a multiline string.
- Parameters:
pad (
tuple[int,int]) – A two-tuple of non-negative integers specifying intra-gate padding (i.e., the horizontal and vertical interior paddings between the content at the centre of each gate (e.g., label) and its outer edge (e.g., block border)). Defaults to(1, 0).sep (
tuple[int,int]) – A two-tuple of non-negative integers specifying inter-gate separation (i.e., the horizontal and vertical exterior separation distances between the edges of neighbouring gates). Defaults to(1, 1).style (
str) – A string specifying the style for the circuit visualization to take. Can be any of"ascii","unicode", or"unicode_alt". Defaults to"unicode".return_string (
bool) – Whether to return the assembled diagram as a multiline string. Defaults toFalse.
- Returns:
None– Returned ifreturn_stringisFalse.str– The rendered circuit diagram. Returned ifreturn_stringisTrue.
Note
The quality of the visualization depends greatly on the output’s configuration. For best results, the terminal should have a monospace font with good Unicode coverage.