monoprop

Pauli

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

A term is the atom a :class:PauliOperator is built from and the generator an :class:~monoprop.circuit.ExpGate gate exponentiates. The placement is local -- the string names only the qubits the term acts on -- so the same term can appear in operators of any width; the total num_qubits lives on the operator, not the term.

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 -- an immutable value object usable as a dictionary key (as :attr:PauliOperator.terms does).

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 :attr: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)) (i.e. a full-width string on qubits 0..len-1).

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