def isitemsimilar(v1, v2, verb=False, dtol=DTOL):

    r = True

    # type checking
    if type(v1) != type(v2):
        r = False
        if verb:
            print("Item has different type", type(v1), type(v2))

    # iterable checking
    elif isinstance(v1, dict):
        r = r and isdicsimilar(v1, v2, verb=verb, dtol=dtol)

    elif isinstance(v1, list):
        r = r and islistsimilar(v1, v2, verb=verb, dtol=dtol)

    # numeric type
    elif isinstance(v1, (int, float)):
        if abs(v1 - v2) > dtol:
            r = False
            if verb:
                print("Key mismatch:", v1, v2)

    # all other types: just check if equal
    else:
        if v1 != v2:
            r = False
            if verb:
                print("Key mismatch:", v1, v2)

    return r
Compare two values for differences
dataset/ETHPy150Open jjhelmus/nmrglue/nmrglue/util/misc.py/isitemsimilar