From b48575fabd64e7d814b69d881bc8b7ee5d332e54 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Wed, 1 Nov 2023 22:28:34 +0100 Subject: [PATCH] fix test --- tests/test_JaroWinkler.py | 2 +- tests/test_hypothesis.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_JaroWinkler.py b/tests/test_JaroWinkler.py index 3c3be42..e03ad8e 100644 --- a/tests/test_JaroWinkler.py +++ b/tests/test_JaroWinkler.py @@ -16,7 +16,7 @@ def test_hash_special_case(self): self._jaro_winkler_similarity([0, -1], [0, -2], 0.66666) def test_edge_case_lengths(self): - self._jaro_winkler_similarity("", "", 0) + self._jaro_winkler_similarity("", "", 1) self._jaro_winkler_similarity("0", "0", 1) self._jaro_winkler_similarity("00", "00", 1) self._jaro_winkler_similarity("0", "00", 0.85) diff --git a/tests/test_hypothesis.py b/tests/test_hypothesis.py index ea92624..67d62ed 100644 --- a/tests/test_hypothesis.py +++ b/tests/test_hypothesis.py @@ -10,8 +10,11 @@ def isclose(a, b, rel_tol=1e-09, abs_tol=0.0): def jaro_similarity(P, T): - P_flag = [0] * (len(P) + 1) - T_flag = [0] * (len(T) + 1) + if not P and not T: + return 1.0 + + P_flag = [False] * (len(P) + 1) + T_flag = [False] * (len(T) + 1) Bound = max(len(P), len(T)) // 2 Bound = max(Bound - 1, 0) @@ -23,8 +26,8 @@ def jaro_similarity(P, T): for j in range(lowlim, hilim + 1): if not P_flag[j] and P[j] == T[i]: - T_flag[i] = 1 - P_flag[j] = 1 + T_flag[i] = True + P_flag[j] = True CommonChars += 1 break