def test_get_dist_func_euclidean(self) -> None: f = LSHNearestNeighborIndex._get_dist_func('euclidean') self.assertIsInstance(f, types.FunctionType) self.assertAlmostEqual( f(np.array([0, 0]), np.array([0, 1])), 1.0 )
def test_get_dist_func_cosine(self) -> None: f = LSHNearestNeighborIndex._get_dist_func('cosine') self.assertIsInstance(f, types.FunctionType) self.assertAlmostEqual( f(np.array([1, 0]), np.array([0, 1])), 1.0 ) self.assertAlmostEqual( f(np.array([1, 0]), np.array([1, 1])), 0.5 )