blob: 3d77df3c15893c49b28d91d32df0b40e9d8f1474 (
plain)
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
|
import pytest
from qolab.data.trace import loadTrace
import numpy as np
def test_load_uncompressed_v0dot1_trace():
tr = loadTrace('tests/trace_test_data/xtrace1.dat')
cfg = tr.getConfig()
assert cfg['config']['version'] == '0.1'
assert cfg['config']['model'] == 'Trace'
data = tr.getData()
assert np.all( (data - np.array([[1], [3], [2], [5]])) == 0 )
def test_load_gzip_compressed_v0dot1_trace():
tr = loadTrace('tests/trace_test_data/xtrace1.dat.gz')
cfg = tr.getConfig()
assert cfg['config']['version'] == '0.1'
assert cfg['config']['model'] == 'Trace'
data = tr.getData()
assert np.all( (data - np.array([[1], [3], [2], [5]])) == 0 )
def test_tryCompressedIfMissing():
fname = 'tests/trace_test_data/only_compressed_file1.dat'
# first we check that the guess is working
tr = loadTrace(fname, tryCompressedIfMissing=True)
cfg = tr.getConfig()
assert cfg['config']['version'] == '0.1'
assert cfg['config']['model'] == 'Trace'
data = tr.getData()
assert np.all( (data - np.array([[1], [3], [2], [5]])) == 0 )
# now we disable search for compressed version
with pytest.raises(FileNotFoundError) as exc_info:
tr = loadTrace(fname, tryCompressedIfMissing=False)
|