qml.pauli.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 or Prod instances specify the same Pauli word.

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, Tensor, SProd, or Prod instances

Example

>>> are_identical_pauli_words(qml.Z(0) @ qml.Z(1), qml.Z(1) @ qml.Z(0))
True
>>> are_identical_pauli_words(qml.I(0) @ qml.X(1), qml.X(1))
True
>>> are_identical_pauli_words(qml.Z(0) @ qml.Z(1), qml.Z(0) @ qml.X(3))
False