qecx.PauliProductOperator

class qecx.PauliProductOperator(_be)

Bases: object

Endianness-typed wrapper for a single Pauli product over {"I", "X", "Y", "Z"}.

Stores the canonical big-endian form (qubit 0 at position 0); the matching little-endian view is available on access. Construct via from_big_endian / from_little_endian and read via the big_endian / little_endian properties; instances built from different endiannesses compare and hash equal whenever they denote the same observable (from_big_endian("IZ") == from_little_endian("ZI")).

Alphabet contract: every character of the input must be in {"I", "X", "Y", "Z"}. No phase is carried, no whitespace is permitted, no signed-Pauli prefix is parsed. __post_init__ raises ValueError listing the offending characters on any alphabet violation.

Variables:
  • _be (str) – Canonical big-endian form of the Pauli product. Stored directly; access externally via big_endian.

  • big_endian (str) – Canonical big-endian view of the Pauli product, with the leftmost character at qubit 0.

  • little_endian (str) – Little-endian view of the Pauli product, with the rightmost character at qubit 0.

classmethod from_big_endian(s)

Construct a PauliProductOperator from a big-endian Pauli string.

Big-endian convention: the leftmost character is qubit 0; s is interpreted as-is and stored as the canonical form. Alphabet validation runs in __post_init__.

Parameters:

s (str) – Big-endian Pauli string over the alphabet {"I", "X", "Y", "Z"}.

Returns:

Wrapper holding s as the canonical form.

Return type:

PauliProductOperator

Raises:

ValueError – If any character of s is outside the alphabet.

classmethod from_little_endian(s)

Construct a PauliProductOperator from a little-endian Pauli string.

Little-endian convention: the rightmost character of s is qubit 0. The input is reversed before storage so that the canonical big-endian form has qubit 0 at position 0. Alphabet validation runs in __post_init__.

Parameters:

s (str) – Little-endian Pauli string over the alphabet {"I", "X", "Y", "Z"}.

Returns:

Wrapper holding the canonical big-endian form equivalent to s.

Return type:

PauliProductOperator

Raises:

ValueError – If any character of s is outside the alphabet.

property big_endian: str

The canonical big-endian view of the Pauli product.

Big-endian convention: the leftmost character corresponds to qubit 0. Returned directly from canonical storage.

Returns:

The Pauli product rendered as a big-endian sequence.

Return type:

str

property little_endian: str

The little-endian view of the Pauli product.

Little-endian convention: the rightmost character corresponds to qubit 0.

Returns:

The Pauli product rendered as a little-endian sequence.

Return type:

str