Skip to content

Commit 19a34fd

Browse files
committed
Add a test to check if wrsamp can write more than 8 channels to fmt516
We should be able to read and write data with more than 8 channels to formats 508, 516, and 524. This test verifies that the digital signal generated when writing to format 516 is identical to the original signal loaded in from a sample record in format 16.
1 parent 0b886ea commit 19a34fd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_record.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,33 @@ def test_read_write_flac_multifrequency(self):
286286
)
287287
assert record == record_write
288288

289+
def test_read_write_flac_many_channels(self):
290+
"""
291+
Check we can read and write to format 516 with more than 8 channels.
292+
"""
293+
# Read in a signal with 12 channels in format 16
294+
record = wfdb.rdrecord("sample-data/s0010_re", physical=False)
295+
296+
# Test that we can write out the signal in format 516
297+
wfdb.wrsamp(
298+
record_name="s0010_re_fmt516",
299+
fs=record.fs,
300+
units=record.units,
301+
sig_name=record.sig_name,
302+
fmt=["516"] * record.n_sig,
303+
d_signal=record.d_signal,
304+
adc_gain=record.adc_gain,
305+
baseline=record.baseline,
306+
write_dir=self.temp_path,
307+
)
308+
309+
# Check that signal matches the original
310+
record_fmt516 = wfdb.rdrecord(
311+
os.path.join(self.temp_path, "s0010_re_fmt516"),
312+
physical=False,
313+
)
314+
assert (record.d_signal == record_fmt516.d_signal).all()
315+
289316
def test_read_flac_longduration(self):
290317
"""
291318
Three signals multiplexed in a FLAC file, over 2**24 samples.

0 commit comments

Comments
 (0)