File: test_basic.py

package info (click to toggle)
python-multipletau 0.1.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 400 kB
  • ctags: 147
  • sloc: python: 1,368; makefile: 14
file content (41 lines) | stat: -rw-r--r-- 1,298 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
basic tests also available in the function docs 
"""
import numpy as np
from os.path import abspath, dirname, join
import sys

sys.path.insert(0, dirname(dirname(abspath(__file__))))

from multipletau import autocorrelate, correlate


def test_ac():
    ist = autocorrelate(range(42), m=2, dtype=np.float_)
    soll = np.array([[  0.00000000e+00,   2.38210000e+04],
                     [  1.00000000e+00,   2.29600000e+04],
                     [  2.00000000e+00,   2.21000000e+04],
                     [  4.00000000e+00,   2.03775000e+04],
                     [  8.00000000e+00,   1.50612000e+04]])
    assert np.allclose(soll, ist)


def test_cc():
    ist = correlate(range(42), range(1,43), m=2, dtype=np.float_)
    soll = np.array([[  0.00000000e+00,   2.46820000e+04],
                     [  1.00000000e+00,   2.38210000e+04],
                     [  2.00000000e+00,   2.29600000e+04],
                     [  4.00000000e+00,   2.12325000e+04],
                     [  8.00000000e+00,   1.58508000e+04]])
    assert np.allclose(soll, ist)

    
if __name__ == "__main__":
    # Run all tests
    loc = locals()
    for key in list(loc.keys()):
        if key.startswith("test_") and hasattr(loc[key], "__call__"):
            loc[key]()