Skip to content

Commit 68bb86d

Browse files
author
Benjamin Moody
committed
test_1c: test reading single-frequency record in non-smooth mode.
When smooth_frames is False, rdrecord should store the signal data as a list of 1D arrays (each signal at its original sampling frequency) rather than as a "smooth" 2D array. Previously, this would fail if the input record contained only one sample per frame. Modify the existing test case to check that this works.
1 parent 7008e47 commit 68bb86d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/test_record.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,30 @@ def test_1b(self):
7575
def test_1c(self):
7676
"""
7777
Format 16, byte offset, selected duration, selected channels,
78-
digital.
78+
digital, expanded format.
7979
8080
Target file created with:
8181
rdsamp -r sample-data/a103l -f 80 -s 0 1 | cut -f 2- > record-1c
8282
"""
8383
record = wfdb.rdrecord('sample-data/a103l',
84-
sampfrom=20000, channels=[0, 1], physical=False)
85-
sig = record.d_signal
84+
sampfrom=20000, channels=[0, 1], physical=False,
85+
smooth_frames=False)
86+
# convert expanded to uniform array
87+
sig = np.zeros((record.sig_len, record.n_sig))
88+
for i in range(record.n_sig):
89+
sig[:,i] = record.e_d_signal[i]
90+
8691
sig_target = np.genfromtxt('tests/target-output/record-1c')
8792

8893
# Compare data streaming from Physionet
8994
record_pn = wfdb.rdrecord('a103l', pn_dir='challenge-2015/training',
9095
sampfrom=20000, channels=[0, 1],
91-
physical=False)
96+
physical=False, smooth_frames=False)
9297

9398
# Test file writing
94-
record.wrsamp()
95-
record_write = wfdb.rdrecord('a103l', physical=False)
99+
record.wrsamp(expanded=True)
100+
record_write = wfdb.rdrecord('a103l', physical=False,
101+
smooth_frames=False)
96102

97103
assert np.array_equal(sig, sig_target)
98104
assert record.__eq__(record_pn)

0 commit comments

Comments
 (0)