hashberg-io / pauliopt

A Python library to simplify quantum circuits of phase and Pauli gadgets.
https://hashberg-io.github.io/pauliopt/
GNU Affero General Public License v3.0
13 stars 9 forks source link

Visualisation #14

Closed daehiff closed 11 months ago

daehiff commented 1 year ago

Enables Visualization (Issue: #10 ) of Pauli Polynomials and latex export.

from pauliopt.pauli.pauli_polynomial import PauliPolynomial
from pauliopt.pauli.pauli_gadget import PPhase
from pauliopt.utils import Angle, pi
from pauliopt.pauli.utils import I, X, Y, Z

pp = PauliPolynomial(5)

pp >>= PPhase(Angle(pi)) @ [I, I, X, Z, Y]
pp >>= PPhase(Angle(pi)) @ [I, I, X, Z, Y]
pp >>= PPhase(Angle(pi / 2)) @ [I, I, X, Z, Y]

display(pp)
 # shows the Pauli Polynomial in jupyter notebooks

pp.to_svg(svg_code_only=True) 
 # provides the SVG code of the Pauli Polynomial

pp.to_latex()
# provides the latex code representing the PP

pp.to_latex(file_name="test")
# stores the Pauli Polynomial in 'text.tex'