import os import re import tempfile import unittest import numpy as np import pandas as pd import wfdb class TestAnnotation(unittest.TestCase): """ Testing read and write of WFDB annotations, including Physionet streaming. Target files created using the original WFDB Software Package version 10.5.24 """ def test_1(self): """ Target file created with: rdann -r sample-data/100 -a atr > ann-1 """ annotation = wfdb.rdann("sample-data/100", "atr") # This is not the fault of the script. The annotation file specifies a # length 3 annotation.aux_note[0] = "(N" # aux_note field with a null written after '(N' which the script correctly picks up. I am just # getting rid of the null in this unit test to compare with the regexp output below which has # no null to detect in the output text file of rdann. # Target data from WFDB software package lines = tuple(open("tests/target-output/ann-1", "r")) nannot = len(lines) target_time = [None] * nannot target_sample = np.empty(nannot, dtype="object") target_symbol = [None] * nannot target_subtype = np.empty(nannot, dtype="object") target_chan = np.empty(nannot, dtype="object") target_num = np.empty(nannot, dtype="object") target_aux_note = [None] * nannot RXannot = re.compile( r"[ \t]*(?P