File: test_open_dat.py

package info (click to toggle)
pyscanfcs 0.3.6%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,412 kB
  • sloc: python: 2,676; makefile: 55; sh: 11
file content (27 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (5)
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
import pathlib

import numpy as np

from pyscanfcs import openfile


def test_open_dat():
    here = pathlib.Path(__file__).parent
    f16 = here / "data/n2000_7.0ms_16bit.dat"
    f32 = here / "data/n2000_7.0ms_32bit.dat"
    info16 = openfile.openDAT(str(f16))
    info32 = openfile.openDAT(str(f32))
    
    assert info16["system_clock"] == 60
    assert info32["system_clock"]== 60
    assert np.all(info16["data_stream"] == info32["data_stream"])
    ref = np.array([1, 1, 21420, 21418, 21420])
    assert np.all(info16["data_stream"][-5:] == ref)


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]()