Example #1
0
 def testComplex(self):
     v = [.1253, .535, .132, .453, -.452, -.33]
     v2 = [.3532, .535, .531, .565, -.4586, .4875]
     actual = knn.by_euclidean_distance(v, v2)
     expected = 0.9444751029010771
     self.assertEquals(actual, expected)
Example #2
0
 def testNegative(self):
     v = [.5, .5, -.25, -.25]
     v2 = [.25, .25, -.5, -.5]
     actual = knn.by_euclidean_distance(v, v2)
     expected = 0.5
     self.assertEquals(actual, expected)
Example #3
0
 def testSimple(self):
     v = [0, 1, 0, 1]
     v2 = [1, 0, 1, 0]
     actual = knn.by_euclidean_distance(v, v2)
     expected = 2.0
     self.assertEquals(actual, expected)
Example #4
0
 def testFloat(self):
     v = [.25, .25, .25, .25]
     v2 = [-.25, -.25, -.25, -.25]
     actual = knn.by_euclidean_distance(v, v2)
     expected = 1.0
     self.assertEquals(actual, expected)
Example #5
0
 def testAllZero(self):
     v = [0]
     v2 = [0]
     actual = knn.by_euclidean_distance(v, v2)
     expected = 0.0
     self.assertEquals(actual, expected)