def testComplex(self): v = [.1253, .535, .132, .453, -.452, -.33] v2 = [.3532, .535, .531, .565, -.4586, .4875] actual = knn.by_inner_product(v, v2) expected = 0.70293016 self.assertEquals(actual, expected)
def testNegative(self): v = [.5, .5, -.25, -.25] v2 = [.25, .25, -.5, -.5] actual = knn.by_inner_product(v, v2) expected = 0.5 self.assertEquals(actual, expected)
def testSimple(self): v = [0, 1, 0, 1] v2 = [1, 0, 1, 0] actual = knn.by_inner_product(v, v2) expected = 0.0 self.assertEquals(actual, expected)
def testFloat(self): v = [.25, .25, .25, .25] v2 = [-.25, -.25, -.25, -.25] actual = knn.by_inner_product(v, v2) expected = -0.25 self.assertEquals(actual, expected)
def testAllZero(self): v = [0] v2 = [0] actual = knn.by_inner_product(v, v2) expected = 0.0 self.assertEquals(actual, expected)