Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a more readable representation for QubitPauliOperator #739

Open
CalMacCQ opened this issue Jan 23, 2023 · 1 comment
Open

Create a more readable representation for QubitPauliOperator #739

CalMacCQ opened this issue Jan 23, 2023 · 1 comment
Labels
enhancement New feature or request stale

Comments

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Jan 23, 2023

Currently printing a QubitPauliOperator (QPO) just gives a dict of the Pauli terms and the weights (to about 15 decimal places) (see below). We could could create a nicer __str__() representation for this or even display it with LaTeX as we do with circuit_to_symbolic_unitary.

from pytket import Circuit, Qubit
from pytket.pauli import Pauli, QubitPauliString
from pytket.utils import QubitPauliOperator

zzi = QubitPauliString({Qubit(0): Pauli.Z, Qubit(1):Pauli.Z, Qubit(2):Pauli.I})
ixy = QubitPauliString({Qubit(0): Pauli.I, Qubit(1):Pauli.X, Qubit(2):Pauli.Y})

qpo = QubitPauliOperator({zzi: 0.2, ixy: 0.7})

print(qpo)

Currently gives...

{(Zq[0], Zq[1], Iq[2]): 0.200000000000000, (Iq[0], Xq[1], Yq[2]): 0.700000000000000}

Another old QPO issue

@CalMacCQ CalMacCQ added the enhancement New feature or request label Jan 23, 2023
@CalMacCQ CalMacCQ changed the title Create readable representation of a QubitPauliOperator Create a more readable representation for QubitPauliOperator Jan 23, 2023
Copy link

This issue has been automatically marked as stale.

@github-actions github-actions bot added the stale label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

1 participant