5
5
class test_annotation ():
6
6
7
7
# Test 1 - Annotation file 100.atr
8
- # Target file created with: rdann -r sample-data/100 -a atr > anntarget1
8
+ # Target file created with: rdann -r sample-data/100 -a atr > ann-1
9
9
def test_1 (self ):
10
10
11
11
# Read data using WFDB python package
12
12
annotation = wfdb .rdann ('sample-data/100' , 'atr' )
13
13
14
-
14
+
15
15
# This is not the fault of the script. The annotation file specifies a
16
16
# length 3
17
17
annotation .aux_note [0 ] = '(N'
@@ -20,7 +20,7 @@ def test_1(self):
20
20
# no null to detect in the output text file of rdann.
21
21
22
22
# Target data from WFDB software package
23
- lines = tuple (open ('tests/target-output/anntarget1 ' , 'r' ))
23
+ lines = tuple (open ('tests/target-output/ann-1 ' , 'r' ))
24
24
nannot = len (lines )
25
25
26
26
target_time = [None ] * nannot
@@ -45,18 +45,18 @@ def test_1(self):
45
45
target_chan = target_chan .astype ('int' )
46
46
47
47
# Compare
48
- comp = [np .array_equal (annotation .sample , target_sample ),
49
- np .array_equal (annotation .symbol , target_symbol ),
50
- np .array_equal (annotation .subtype , target_subtype ),
51
- np .array_equal (annotation .chan , target_chan ),
52
- np .array_equal (annotation .num , target_num ),
48
+ comp = [np .array_equal (annotation .sample , target_sample ),
49
+ np .array_equal (annotation .symbol , target_symbol ),
50
+ np .array_equal (annotation .subtype , target_subtype ),
51
+ np .array_equal (annotation .chan , target_chan ),
52
+ np .array_equal (annotation .num , target_num ),
53
53
annotation .aux_note == target_aux_note ]
54
54
55
55
# Test file streaming
56
56
pbannotation = wfdb .rdann ('100' , 'atr' , pb_dir = 'mitdb' , return_label_elements = ['label_store' , 'symbol' ])
57
57
pbannotation .aux_note [0 ] = '(N'
58
58
pbannotation .create_label_map ()
59
-
59
+
60
60
# Test file writing
61
61
annotation .wrann (write_fs = True )
62
62
writeannotation = wfdb .rdann ('100' , 'atr' , return_label_elements = ['label_store' , 'symbol' ])
@@ -67,14 +67,14 @@ def test_1(self):
67
67
assert annotation .__eq__ (writeannotation )
68
68
69
69
# Test 2 - Annotation file 12726.anI with many aux_note strings.
70
- # Target file created with: rdann -r sample-data/100 -a atr > anntarget2
70
+ # Target file created with: rdann -r sample-data/100 -a atr > ann-2
71
71
def test_2 (self ):
72
72
73
73
# Read data from WFDB python package
74
74
annotation = wfdb .rdann ('sample-data/12726' , 'anI' )
75
75
76
76
# Target data from WFDB software package
77
- lines = tuple (open ('tests/target-output/anntarget2 ' , 'r' ))
77
+ lines = tuple (open ('tests/target-output/ann-2 ' , 'r' ))
78
78
nannot = len (lines )
79
79
80
80
target_time = [None ] * nannot
@@ -99,11 +99,11 @@ def test_2(self):
99
99
target_chan = target_chan .astype ('int' )
100
100
101
101
# Compare
102
- comp = [np .array_equal (annotation .sample , target_sample ),
103
- np .array_equal (annotation .symbol , target_symbol ),
104
- np .array_equal (annotation .subtype , target_subtype ),
105
- np .array_equal (annotation .chan , target_chan ),
106
- np .array_equal (annotation .num , target_num ),
102
+ comp = [np .array_equal (annotation .sample , target_sample ),
103
+ np .array_equal (annotation .symbol , target_symbol ),
104
+ np .array_equal (annotation .subtype , target_subtype ),
105
+ np .array_equal (annotation .chan , target_chan ),
106
+ np .array_equal (annotation .num , target_num ),
107
107
annotation .aux_note == target_aux_note ]
108
108
# Test file streaming
109
109
pbannotation = wfdb .rdann ('12726' , 'anI' , pb_dir = 'prcp' , return_label_elements = ['label_store' , 'symbol' ])
@@ -119,14 +119,14 @@ def test_2(self):
119
119
assert annotation .__eq__ (writeannotation )
120
120
121
121
# Test 3 - Annotation file 1003.atr with custom annotation types
122
- # Target file created with: rdann -r sample-data/1003 -a atr > anntarget3
122
+ # Target file created with: rdann -r sample-data/1003 -a atr > ann-3
123
123
def test_3 (self ):
124
124
125
125
# Read data using WFDB python package
126
126
annotation = wfdb .rdann ('sample-data/1003' , 'atr' )
127
127
128
128
# Target data from WFDB software package
129
- lines = tuple (open ('tests/target-output/anntarget3 ' , 'r' ))
129
+ lines = tuple (open ('tests/target-output/ann-3 ' , 'r' ))
130
130
nannot = len (lines )
131
131
132
132
target_time = [None ] * nannot
@@ -151,11 +151,11 @@ def test_3(self):
151
151
target_chan = target_chan .astype ('int' )
152
152
153
153
# Compare
154
- comp = [np .array_equal (annotation .sample , target_sample ),
155
- np .array_equal (annotation .symbol , target_symbol ),
156
- np .array_equal (annotation .subtype , target_subtype ),
157
- np .array_equal (annotation .chan , target_chan ),
158
- np .array_equal (annotation .num , target_num ),
154
+ comp = [np .array_equal (annotation .sample , target_sample ),
155
+ np .array_equal (annotation .symbol , target_symbol ),
156
+ np .array_equal (annotation .subtype , target_subtype ),
157
+ np .array_equal (annotation .chan , target_chan ),
158
+ np .array_equal (annotation .num , target_num ),
159
159
annotation .aux_note == target_aux_note ]
160
160
161
161
# Test file streaming
0 commit comments