Skip to content

Commit ddf4e20

Browse files
authored
Test round-trip write/read of supported binary formats (#509)
We want to test that both reading and writing work correctly for all supported formats (although currently some binary formats are completely unsupported for writing.) Previous test cases covered formats 80, 212, 16, and 24 (and the FLAC formats) but did not cover format 32.
2 parents 9c20204 + 2a9feb5 commit ddf4e20

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_record.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,27 @@ def test_1f(self):
227227
"Mismatch in %s" % name,
228228
)
229229

230+
# Test writing all supported formats. (Currently not all signal
231+
# formats are supported for output; keep this list in sync with
232+
# 'wr_dat_file' in wfdb/io/_signal.py.)
233+
OUTPUT_FMTS = ["80", "212", "16", "24", "32"]
234+
channels = []
235+
for i, fmt in enumerate(record.fmt):
236+
if fmt in OUTPUT_FMTS:
237+
channels.append(i)
238+
239+
partial_record = wfdb.rdrecord(
240+
"sample-data/binformats",
241+
physical=False,
242+
channels=channels,
243+
)
244+
partial_record.wrsamp(write_dir=self.temp_path)
245+
converted_record = wfdb.rdrecord(
246+
os.path.join(self.temp_path, "binformats"),
247+
physical=False,
248+
)
249+
assert partial_record == converted_record
250+
230251
def test_read_write_flac(self):
231252
"""
232253
All FLAC formats, multiple signal files in one record.

0 commit comments

Comments
 (0)