qml.grouping.are_identical_pauli_words

are_identical_pauli_words(pauli_1, pauli_2)[source]

Performs a check if two Pauli words have the same wires and name attributes.

This is a convenience function that checks if two given Tensor instances specify the same Pauli word. This function only checks if both Tensor instances have the same wires and name attributes, and hence won’t perform any simplification to identify if the two Pauli words are algebraically equivalent. For instance, this function will not identify that PauliX(0) @ PauliX(0) = Identity(0), or PauliX(0) @ Identity(1) = PauliX(0), or Identity(0) = Identity(1), etc.

Parameters
Returns

whether pauli_1 and pauli_2 have the same wires and name attributes

Return type

bool

Raises

TypeError – if pauli_1 or pauli_2 are not Identity, PauliX, PauliY, PauliZ, or Tensor instances

Example

>>> are_identical_pauli_words(qml.PauliZ(0) @ qml.PauliZ(1), qml.PauliZ(0) @ qml.PauliZ(1))
True
>>> are_identical_pauli_words(qml.PauliZ(0) @ qml.PauliZ(1), qml.PauliZ(0) @ qml.PauliX(3))
False