Ejemplo n.º 1
0
 def test_precision(self, ratio):
     """zipstance(a, x*a + (1 - x)*b) ~ 1 - x, if zipstance(a, b) ~ 1"""
     eps = 0.02
     n = 10000
     a = ''.join([random.choice(string.ascii_letters + '. ') for _ in range(n)])
     b = ''.join([random.choice(string.ascii_letters + '. ') for _ in range(n)])
     dist = zipstance(a, a[0:int(ratio*n)] + b[int(ratio*n):])
     self.assertTrue(dist >= 1 - ratio - eps)
     self.assertTrue(dist <= 1 - ratio + eps)
Ejemplo n.º 2
0
 def test_triangle_inequality(self, a, b, c):
     self.assertTrue(zipstance(a, c) <= zipstance(a, b) + zipstance(b, c))
Ejemplo n.º 3
0
 def test_coincidence(self, a, b):
     aa = zipstance(a, a)
     bb = zipstance(b, b)
     ab = zipstance(a, b)
     self.assertTrue(aa <= ab)
     self.assertTrue(bb <= ab)
Ejemplo n.º 4
0
 def test_symmetry(self, a, b):
     eps = 0.02
     ab = zipstance(a, b)
     ba = zipstance(b, a)
     self.assertTrue(ab <= ba + eps)
     self.assertTrue(ab >= ba - eps)
Ejemplo n.º 5
0
 def test_positivity(self, a, b):
     self.assertTrue(zipstance(a, b) >= 0)