qml.grouping.pauli_word_to_string¶
-
pauli_word_to_string
(pauli_word, wire_map=None)[source]¶ Convert a Pauli word from a tensor to a string.
Given a Pauli in observable form, convert it into string of characters from
['I', 'X', 'Y', 'Z']
. This representation is required for functions such asPauliRot
.- Parameters
pauli_word (Observable) – an observable, either a
Tensor
instance or single-qubit observable representing a Pauli group element.wire_map (dict[Union[str, int], int]) – dictionary containing all wire labels used in the Pauli word as keys, and unique integer labels as their values
- Returns
The string representation of the observable in terms of
'I'
,'X'
,'Y'
, and/or'Z'
.- Return type
str
- Raises
TypeError – if the input observable is not a proper Pauli word.
Example
>>> wire_map = {'a' : 0, 'b' : 1, 'c' : 2} >>> pauli_word = qml.PauliX('a') @ qml.PauliY('c') >>> pauli_word_to_string(pauli_word, wire_map=wire_map) 'XIY'
code/api/pennylane.grouping.pauli_word_to_string
Download Python script
Download Notebook
View on GitHub