monoprop

Pauli

A single Pauli term: Pauli letters placed on specific qubits.

The placement is local -- the string names only the qubits the term acts on, so a term fits an operator of any width and the total num_qubits lives on PauliOperator, not here.

Terms are canonicalized on construction: identity (I) letters are dropped and the remaining (qubit, letter) pairs are sorted by qubit, so Pauli("XY", (1, 0)) and Pauli("YX", (0, 1)) compare equal and hash alike, making the term usable as a dict key.

Attributes

attribute__slots__
= ('qubits', 'string')
attributequbits
= tuple(q for q, _ in pairs)

The (sorted, distinct) qubit indices the letters act on.

attributestring
= ''.join(p for _, p in pairs)

The non-identity Pauli letters, ordered to match qubits.

Functions

func__init__(self, string, qubits=None) -> None

Initialize the Pauli term.

paramself
paramstringstr

Pauli letters (each one of I, X, Y, Z).

paramqubitsint | Sequence[int] | None
= None

Qubit index or indices the letters act on; defaults to range(len(string)).

Returns

None
func__eq__(self, other) -> bool

Two Pauli terms are equal when their letters and qubits match (post-canonicalization).

paramself
paramotherobject

Returns

bool
func__hash__(self) -> int

Hash on the canonical (string, qubits) so equal terms share a bucket.

paramself

Returns

int
func__repr__(self) -> str

Return a string representation such as Pauli('ZZ', (0, 1)).

paramself

Returns

str

On this page