PauliTerm.pauli_string

PauliTerm.pauli_string(qubits=None)[source]

Return a string representation of this PauliTerm without its coefficient and with implicit qubit indices.

If a list of qubits is provided, each character in the resulting string represents a Pauli operator on the corresponding qubit. If qubit indices are not provided as input, the returned string will be all non-identity operators in the order. This doesn’t make much sense, so please provide a list of qubits. Not providing a list of qubits is deprecated.

>>> p = PauliTerm("X", 0) * PauliTerm("Y", 1, 1.j)
>>> p.pauli_string()
"XY"
>>> p.pauli_string(qubits=[0])
"X"
>>> p.pauli_string(qubits=[0, 2])
"XI"
Parameters:qubits (list) – The list of qubits to represent, given as ints. If None, defaults to all qubits in this PauliTerm.
Returns:The string representation of this PauliTerm, sans coefficient