Ejemplo n.º 1
0
    def test_same_result(self):
        a = random_walk(1, 10000, 508842746).reshape(10000)
        nlags = 100
        msd_slow = hdt.msd(a, nlags=nlags, fft=False)
        msd_fast = hdt.msd(a, nlags=nlags, fft=True)
        assert_almost_equal(msd_slow, msd_fast)

        b = random_walk(3, 10000)
        msd_slow = hdt.msd(b, nlags=nlags, fft=False)
        msd_fast = hdt.msd(b, nlags=nlags, fft=True)
        assert_almost_equal(msd_slow, msd_fast)
Ejemplo n.º 2
0
 def test_msd_arange_fft(self):
     a = np.arange(90)
     msd = hdt.msd(a)
     assert (len(a) - 1) == len(msd)
     # for a few values the result is off by about 0.33. I don't know where
     # this comes from but this solution is only a good aproxximation for
     # large values of N anyway
     assert_almost_equal((a**2)[:-1], msd, decimal=0)
Ejemplo n.º 3
0
 def test_ValueError(self):
     a = np.ones((3, 3, 3))
     with pytest.raises(ValueError):
         hdt.msd(a)
Ejemplo n.º 4
0
 def test_array_like(self):
     a = list(np.arange(9))
     msd = hdt.msd(a, fft=False)
     assert 8 == len(msd)
     assert_almost_equal(np.power(a, 2)[:-1], msd)
Ejemplo n.º 5
0
 def test_msd_constant_fft(self):
     a = np.ones(9) * 42
     msd = hdt.msd(a)
     assert_almost_equal(np.zeros(len(a) - 1), msd)
Ejemplo n.º 6
0
 def test_msd_arange_slow(self):
     a = np.arange(9)
     msd = hdt.msd(a, fft=False)
     assert 8 == len(msd)
     assert_almost_equal((a**2)[:-1], msd)