def is_zero(pauli_object):
    """
    Tests to see if a PauliTerm or PauliSum is zero.

    :param pauli_object: Either a PauliTerm or PauliSum
    :returns: True if PauliTerm is zero, False otherwise
    :rtype: bool
    """
    if isinstance(pauli_object, PauliTerm):
        return np.isclose(pauli_object.coefficient, 0)
    elif isinstance(pauli_object, PauliSum):
        return len(pauli_object.terms) == 1 and np.isclose(pauli_object.terms[0].coefficient, 0)
    else:
        raise TypeError("is_zero only checks PauliTerms and PauliSum objects!")
def is_zero ( pauli_object ) : if isinstance ( pauli_object , PauliTerm ) : return np . isclose ( pauli_object . coefficient , 0 ) elif isinstance ( pauli_object , PauliSum ) : return len ( pauli_object . terms ) == 1 and np . isclose ( pauli_object . terms [ 0 ] . coefficient , 0 ) else : raise TypeError ( "is_zero only checks PauliTerms and PauliSum objects!" )
Tests to see if a PauliTerm or PauliSum is zero.

    :param pauli_object: Either a PauliTerm or PauliSum
    :returns: True if PauliTerm is zero, False otherwise
    :rtype: bool