-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_class.py
51 lines (40 loc) · 1.39 KB
/
test_class.py
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
42
43
44
45
46
47
48
49
50
51
from .ECG_Class import ECG_Class
from .take_average import average
from .HRinst import HRinst
from .tachybradycardia import bradycardia, tachycardia
from glob import glob
files = glob('test_data*.csv')
def test_unpack():
for f in files:
obj1 = ECG_Class(f)
assert obj1.name == f[:-4]
assert len(obj1.time) == len(obj1.data[0][:])
assert len(obj1.voltage) == len(obj1.data[0][:])
assert type(obj1.data) == tuple
def test_defaults():
for f in files:
obj1 = ECG_Class(files[0])
assert obj1.mins == 1
assert obj1.outputfile == "test_data1_output.txt"
assert obj1.bradyT == 60
assert obj1.tachyT == 100
def test_average():
for f in files:
obj2 = ECG_Class(f, avemins=2)
assert obj2.mins == 2
assert obj2.avg() == average(obj2.instHR, obj2.time, obj2.mins)
def test_btc():
for f in files:
obj2 = ECG_Class(f)
obj3 = ECG_Class(f, lowerThresh=50, upperThresh=110)
assert obj2.bradyT == 60
assert obj2.tachyT == 100
assert obj3.bradyT == 50
assert obj3.tachyT == 110
assert obj3.brady() == bradycardia(obj3.instHR, obj3.bradyT)
assert obj2.tachy() == tachycardia(obj2.instHR, obj2.tachyT)
def test_inst():
import numpy as np
for f in files:
obj1 = ECG_Class(f)
assert np.all(obj1.instHR == HRinst(obj1.data))