PauliSum

class braket.quantum_information.pauli_sum.PauliSum(terms=())[source]

Bases: object

A weighted sum of Pauli strings.

Parameters:

terms (Iterable[tuple[Number, str | PauliString]])

Initializes a PauliSum.

Parameters:

terms (Iterable[tuple[Number, str | PauliString]]) – Pairs of coefficient and Pauli string.

property all_terms_commute: bool

Whether all terms in the sum commute with each other.

Type:

bool

classmethod from_list(terms)[source]

Builds a PauliSum from a list of weighted Pauli strings.

Parameters:

terms (Iterable[tuple[Number, str | PauliString]])

Return type:

PauliSum

property terms: tuple[tuple[Number, PauliString], ...]

The weighted Pauli terms.

Type:

tuple[tuple[numbers.Number, PauliString], …]

property qubit_count: int

The number of qubits in the largest Pauli string term.

Type:

int

to_list()[source]

Returns a list representation of the weighted Pauli strings.

Return type:

list[tuple[Number, str]]

to_sum()[source]

Converts the weighted Pauli strings into a circuit Sum observable.

Return type:

Sum

commutes_with(other)[source]

Returns whether all terms commute with other.

Parameters:

other (PauliSum | PauliString | str)

Return type:

bool

is_self_commuting()[source]

Returns whether all terms in this sum commute with each other.

Return type:

bool

classmethod from_sum(observable_sum)[source]

Builds a PauliSum from a circuit Sum observable.

Parameters:

observable_sum (Sum)

Return type:

PauliSum

braket.quantum_information.pauli_sum.PauliStringSum

alias of PauliSum