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) -> NoneInitialize the Pauli term.
paramselfparamstringstrPauli letters (each one of I, X, Y, Z).
paramqubitsint | Sequence[int] | None= NoneQubit index or indices the letters act on. Defaults to
range(len(string)) (i.e. a full-width string on qubits 0..len-1).
Returns
Nonefunc__eq__(self, other) -> boolTwo Pauli terms are equal when their letters and qubits match (post-canonicalization).
paramselfparamotherobjectReturns
boolfunc__hash__(self) -> intHash on the canonical (string, qubits) so equal terms share a bucket.
paramselfReturns
intfunc__repr__(self) -> strReturn a string representation such as Pauli('ZZ', (0, 1)).
paramselfReturns
str