-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee5fb0c
commit 13d466a
Showing
4 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from __future__ import annotations | ||
import unittest | ||
from limestone import jaro | ||
|
||
class TestJaro(unittest.TestCase): | ||
def test_distance_diff(self): | ||
dist = jaro.distance("ACTG", "FHYU") | ||
self.assertEqual(dist, 1.0) | ||
|
||
def test_similarity_diff(self): | ||
sim = jaro.similarity("ACTG", "FHYU") | ||
self.assertEqual(sim, 0.0) | ||
|
||
def test_norm_distance_diff(self): | ||
dist = jaro.normalized_distance("ACTG", "FHYU") | ||
self.assertEqual(dist, 1.0) | ||
|
||
def test_norm_similarity_diff(self): | ||
sim = jaro.normalized_similarity("ACTG", "FHYU") | ||
self.assertEqual(sim, 0.0) | ||
|
||
def test_distance_sim(self): | ||
dist = jaro.distance("ACTG", "ACTG") | ||
self.assertEqual(dist, 0.0) | ||
|
||
def test_similarity_sim(self): | ||
sim = jaro.similarity("ACTG", "ACTG") | ||
self.assertEqual(sim, 1.0) | ||
|
||
def test_norm_distance_sim(self): | ||
dist = jaro.normalized_distance("ACTG", "ACTG") | ||
self.assertEqual(dist, 0.0) | ||
|
||
def test_norm_similarity_sim(self): | ||
sim = jaro.normalized_similarity("ACTG", "ACTG") | ||
self.assertEqual(sim, 1.0) | ||
|
||
def test_norm_distance1(self): | ||
dist = jaro.normalized_distance("ACTG", "AATG") | ||
self.assertEqual(dist, 0.17) | ||
|
||
def test_norm_distance2(self): | ||
dist = jaro.normalized_distance("ACTG", "AAAG") | ||
self.assertEqual(dist, 0.33) | ||
|
||
def test_norm_distance3(self): | ||
dist = jaro.normalized_distance("ACTG", "AAAA") | ||
self.assertEqual(dist, 0.5) | ||
|
||
def test_norm_similarity1(self): | ||
dist = jaro.normalized_similarity("ACTG", "AATG") | ||
self.assertEqual(dist, 0.83) | ||
|
||
def test_norm_similarity2(self): | ||
dist = jaro.normalized_similarity("ACTG", "AAAG") | ||
self.assertEqual(dist, 0.67) | ||
|
||
def test_norm_similarity3(self): | ||
dist = jaro.normalized_similarity("ACTG", "AAAA") | ||
self.assertEqual(dist, 0.5) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from __future__ import annotations | ||
import unittest | ||
from limestone import jaro_winkler | ||
|
||
class TestJaroWinkler(unittest.TestCase): | ||
def test_distance_diff(self): | ||
dist = jaro_winkler.distance("ACTG", "FHYU") | ||
self.assertEqual(dist, 1.0) | ||
|
||
def test_similarity_diff(self): | ||
sim = jaro_winkler.similarity("ACTG", "FHYU") | ||
self.assertEqual(sim, 0.0) | ||
|
||
def test_norm_distance_diff(self): | ||
dist = jaro_winkler.normalized_distance("ACTG", "FHYU") | ||
self.assertEqual(dist, 1.0) | ||
|
||
def test_norm_similarity_diff(self): | ||
sim = jaro_winkler.normalized_similarity("ACTG", "FHYU") | ||
self.assertEqual(sim, 0.0) | ||
|
||
def test_distance_sim(self): | ||
dist = jaro_winkler.distance("ACTG", "ACTG") | ||
self.assertEqual(dist, 0.0) | ||
|
||
def test_similarity_sim(self): | ||
sim = jaro_winkler.similarity("ACTG", "ACTG") | ||
self.assertEqual(sim, 1.0) | ||
|
||
def test_norm_distance_sim(self): | ||
dist = jaro_winkler.normalized_distance("ACTG", "ACTG") | ||
self.assertEqual(dist, 0.0) | ||
|
||
def test_norm_similarity_sim(self): | ||
sim = jaro_winkler.normalized_similarity("ACTG", "ACTG") | ||
self.assertEqual(sim, 1.0) | ||
|
||
def test_norm_distance1(self): | ||
dist = jaro_winkler.normalized_distance("ACTG", "AATG") | ||
self.assertEqual(dist, 0.15) | ||
|
||
def test_norm_distance2(self): | ||
dist = jaro_winkler.normalized_distance("ACTG", "AAAG") | ||
self.assertEqual(dist, 0.3) | ||
|
||
def test_norm_distance3(self): | ||
dist = jaro_winkler.normalized_distance("ACTG", "AAAA") | ||
self.assertEqual(dist, 0.45) | ||
|
||
def test_norm_similarity1(self): | ||
dist = jaro_winkler.normalized_similarity("ACTG", "AATG") | ||
self.assertEqual(dist, 0.85) | ||
|
||
def test_norm_similarity2(self): | ||
dist = jaro_winkler.normalized_similarity("ACTG", "AAAG") | ||
self.assertEqual(dist, 0.7) | ||
|
||
def test_norm_similarity3(self): | ||
dist = jaro_winkler.normalized_similarity("ACTG", "AAAA") | ||
self.assertEqual(dist, 0.55) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |