def _le(val1, val2) -> float: """Distance computation for '<='""" if val1 <= val2: return 0.0 if is_numeric(val1) and is_numeric(val2): return (val1 - val2) + 1.0 return inf
def _eq(val1, val2) -> float: """Distance computation for '=='""" if val1 == val2: return 0.0 if is_numeric(val1) and is_numeric(val2): return abs(val1 - val2) if is_string(val1) and is_string(val2): return levenshtein_distance(val1, val2) return inf
def _le(val1, val2) -> float: """Distance computation for '<=' Args: val1: the first value val2: the second value Returns: the distance """ if val1 <= val2: return 0.0 if is_numeric(val1) and is_numeric(val2): return (val1 - val2) + 1.0 return inf
def _eq(val1, val2) -> float: """Distance computation for '==' Args: val1: the first value val2: the second value Returns: the distance """ if val1 == val2: return 0.0 if is_numeric(val1) and is_numeric(val2): return abs(val1 - val2) if is_string(val1) and is_string(val2): return levenshtein_distance(val1, val2) return inf
def test_is_numeric(value, result): assert is_numeric(value) == result