rqutils.qprint module
Pretty-printer for quantum objects (rqutils.qprint)
QPrint API
- rqutils.qprint.qprint(qobj: Any, fmt: str = 'braket', amp_norm: Number | tuple[Number, str] | None = None, phase_norm: tuple[Number, str] | None = (3.141592653589793, 'π'), global_phase: Number | str | None = None, terms_per_row: int = 0, amp_format: str = '.3f', phase_format: str = '.2f', amp_cutoff: float = 0.0005, lhs_label: str | None = None, dim: ArrayLike | None = None, binary: bool = False, symbol: str | Sequence[str] | Sequence[Sequence[str]] | None = None, delimiter: str = '', output: str = 'latex') PrintReturnType
Pretty-print a quantum object.
Available output formats are
‘braket’: For a column vector, row vector, or matrix input. Prints out the mathematical expression of the linear combination of bras, kets, or ket-bras.
‘pauli’: For an input representing a square matrix (shape (d1*d2*…, d1*d2*…)) or a components array (shape (d1**2, d2**2, …)). Argument dim is required for the matrix interpretation.
‘matrix’: For a square matrix input. Arguments dim, binary, symbol, and delimiter are ignored.
Three printing formats are supported:
‘text’: Print text to stdout.
‘latex’: Return a LaTeX string.
‘mpl’: Return a matplotlib figure.
- Parameters:
qobj – Input quantum object.
fmt – Print format (‘braket’ or ‘pauli’).
amp_norm – Specification of the normalization of amplitudes by (numeric devisor, unit in LaTeX).
phase_norm – Specification of the normalization of phases by (numeric devisor, unit in LaTeX).
global_phase – Specification of the phase to factor out. Give a numeric offset or ‘mean’.
terms_per_row – Number of terms to show per row.
amp_format – Format for the numerical value of the amplitude absolute values.
phase_format – Format for the numerical value of the phases.
amp_cutoff – Ignore terms with absolute amplitudes less than
max(abs(amplitudes))times this value.lhs_label – If not None, prepend ‘label = ‘ to the printout.
dim – Specification of the dimensions of the subsystems. For fmt=’pauli’, used only when qobj is a square matrix or a 1D array.
binary – Show bra and ket indices in binary. Only for fmt=’braket’.
symbol – Pauli matrix symbols. Only for fmt=’pauli’.
delimiter – Pauli product delimiter. Only for fmt=’pauli’.
output – Output method (‘text’, ‘latex’, or ‘mpl’).
- Returns:
Object to be printed.