def compare(self, other):
    'Compares with another :class:`~.Hamiltonian`, :class:`~Tensor`, or :class:`~Observable`,\n        to determine if they are equivalent.\n\n        Observables/Hamiltonians are equivalent if they represent the same operator\n        (their matrix representations are equal), and they are defined on the same wires.\n\n        .. Warning::\n\n            The compare method does **not** check if the matrix representation\n            of a :class:`~.Hermitian` observable is equal to an equivalent\n            observable expressed in terms of Pauli matrices.\n            To do so would require the matrix form of Hamiltonians and Tensors\n            be calculated, which would drastically increase runtime.\n\n        Returns:\n            (bool): True if equivalent.\n\n        **Examples**\n\n        >>> ob1 = qml.PauliX(0) @ qml.Identity(1)\n        >>> ob2 = qml.Hamiltonian([1], [qml.PauliX(0)])\n        >>> ob1.compare(ob2)\n        True\n        >>> ob1 = qml.PauliX(0)\n        >>> ob2 = qml.Hermitian(np.array([[0, 1], [1, 0]]), 0)\n        >>> ob1.compare(ob2)\n        False\n        '
    if isinstance(other, (Tensor, Observable)):
        return (other._obs_data() == self._obs_data())
    if isinstance(other, qml.Hamiltonian):
        return other.compare(self)
    raise ValueError('Can only compare an Observable/Tensor, and a Hamiltonian/Observable/Tensor.')
Compares with another :class:`~.Hamiltonian`, :class:`~Tensor`, or :class:`~Observable`,
to determine if they are equivalent.

Observables/Hamiltonians are equivalent if they represent the same operator
(their matrix representations are equal), and they are defined on the same wires.

.. Warning::

    The compare method does **not** check if the matrix representation
    of a :class:`~.Hermitian` observable is equal to an equivalent
    observable expressed in terms of Pauli matrices.
    To do so would require the matrix form of Hamiltonians and Tensors
    be calculated, which would drastically increase runtime.

Returns:
    (bool): True if equivalent.

**Examples**

>>> ob1 = qml.PauliX(0) @ qml.Identity(1)
>>> ob2 = qml.Hamiltonian([1], [qml.PauliX(0)])
>>> ob1.compare(ob2)
True
>>> ob1 = qml.PauliX(0)
>>> ob2 = qml.Hermitian(np.array([[0, 1], [1, 0]]), 0)
>>> ob1.compare(ob2)
False
def compare(self, other):
    'Compares with another :class:`~.Hamiltonian`, :class:`~Tensor`, or :class:`~Observable`,\n        to determine if they are equivalent.\n\n        Observables/Hamiltonians are equivalent if they represent the same operator\n        (their matrix representations are equal), and they are defined on the same wires.\n\n        .. Warning::\n\n            The compare method does **not** check if the matrix representation\n            of a :class:`~.Hermitian` observable is equal to an equivalent\n            observable expressed in terms of Pauli matrices.\n            To do so would require the matrix form of Hamiltonians and Tensors\n            be calculated, which would drastically increase runtime.\n\n        Returns:\n            (bool): True if equivalent.\n\n        **Examples**\n\n        >>> ob1 = qml.PauliX(0) @ qml.Identity(1)\n        >>> ob2 = qml.Hamiltonian([1], [qml.PauliX(0)])\n        >>> ob1.compare(ob2)\n        True\n        >>> ob1 = qml.PauliX(0)\n        >>> ob2 = qml.Hermitian(np.array([[0, 1], [1, 0]]), 0)\n        >>> ob1.compare(ob2)\n        False\n        '
    if isinstance(other, (Tensor, Observable)):
        return (other._obs_data() == self._obs_data())
    if isinstance(other, qml.Hamiltonian):
        return other.compare(self)
    raise ValueError('Can only compare an Observable/Tensor, and a Hamiltonian/Observable/Tensor.')