Suppose I have a PauliSumOp
as follows:
from qiskit.opflow import X, Z, I, Y
h = (X ^ X ^ I) + (I ^ Y ^ Y) + (Z ^ Z ^ X)
I would like to go over the Pauli strings and do something with each string (for example, I need to know the positions of nontrivial Pauli matrices, but that's beside the point). I can iterate over h
:
for k in h:
...
In this case, k
will be a PauliSumOp
with one Pauli string and one weight. The trouble is, I can't understand how to get the string itself (for example as a str
, but a PauliOp
will also do).
Is there a recommended way to extract individual Pauli strings from a PauliSumOp
?