def test_simple(self): d = 2 n, m = 200, 200 np.random.seed(1) x = np.random.randn(n, d) y = np.random.randn(m, d) # Almost identical samples dm = xca.nearest_neighbor(x + 0.001, x) assert_almost_equal(dm, 0, 2) # Same distribution but mixed dm = xca.nearest_neighbor(x, y) assert_almost_equal(dm, 0.5, 1) # Two completely different distributions dm = xca.nearest_neighbor(x + 10, y) assert_almost_equal(dm, 1, 2)
def test_compare_with_matlab(self): x, y = matlab_sample() dm = xca.nearest_neighbor(x, y) assert_almost_equal(dm, 1, 4)