コード例 #1
0
ファイル: test_analog.py プロジェクト: Ouranosinc/xclim
    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)
コード例 #2
0
ファイル: test_analog.py プロジェクト: Ouranosinc/xclim
 def test_compare_with_matlab(self):
     x, y = matlab_sample()
     dm = xca.nearest_neighbor(x, y)
     assert_almost_equal(dm, 1, 4)