-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_heuristics.py
59 lines (40 loc) · 1.64 KB
/
test_heuristics.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
52
53
54
55
56
57
58
59
import pathlib
import bletl
dir_testfiles = pathlib.Path(pathlib.Path(__file__).absolute().parent, "data")
FP_TESTFILE = pathlib.Path(dir_testfiles, "BLPro", "107-AR_Coryne-AR-2019-04-15-12-39-30.csv")
class TestDOPeakDetection:
def test_find_peak(self):
bldata = bletl.parse(FP_TESTFILE)
x, y = bldata["DO"].get_timeseries("A01")
c_peak = bletl.find_do_peak(
x, y, delay_a=0.5, threshold_a=70, delay_b=0, threshold_b=80, initial_delay=1
)
assert c_peak == 60
return
def test_find_no_peak_with_long_delay_a(self):
bldata = bletl.parse(FP_TESTFILE)
x, y = bldata["DO"].get_timeseries("A01")
# The DO was below 70 for only ~2 h
c_peak = bletl.find_do_peak(
x, y, delay_a=5, threshold_a=70, delay_b=0, threshold_b=80, initial_delay=1
)
assert c_peak is None
return
def test_find_no_peak_with_long_delay_b(self):
bldata = bletl.parse(FP_TESTFILE)
x, y = bldata["DO"].get_timeseries("A01")
# The series continues for only ~9.5 h after the peak
c_peak = bletl.find_do_peak(
x, y, delay_a=0.5, threshold_a=70, delay_b=12, threshold_b=80, initial_delay=1
)
assert c_peak is None
return
def test_find_no_peak_with_long_initial_delay(self):
bldata = bletl.parse(FP_TESTFILE)
x, y = bldata["DO"].get_timeseries("A01")
# The peak is within the first ~12 h
c_peak = bletl.find_do_peak(
x, y, delay_a=0.5, threshold_a=70, delay_b=4, threshold_b=80, initial_delay=15
)
assert c_peak is None
return