qml.pauli.PauliWord

class PauliWord(mapping)[source]

Bases: dict

Immutable dictionary used to represent a Pauli Word, associating wires with their respective operators. Can be constructed from a standard dictionary.

>>> w = PauliWord({"a": 'X', 2: 'Y', 3: 'Z'})
>>> w
X(a) @ Y(2) @ Z(3)

wires

Track wires in a PauliWord.

wires

Track wires in a PauliWord.

to_mat(wire_order[, format])

Returns the matrix representation.

update(_PauliWord__m, **kwargs)

Restrict updating PW after instantiation.

to_mat(wire_order, format='dense')[source]

Returns the matrix representation.

Keyword Arguments
  • wire_order (iterable or None) – The order of qubits in the tensor product.

  • format (str) – The format of the matrix (“dense” by default), if not a dense matrix, then the format for the sparse representation of the matrix.

Returns

Matrix representation of the Pauliword

Return type

(Union[NumpyArray, ScipySparseArray])

Raises

ValueError – Can’t get the matrix of an empty PauliWord.

update(_PauliWord__m, **kwargs)None[source]

Restrict updating PW after instantiation.