Skip to content

Commit cac2af6

Browse files
author
Benjamin Moody
committed
SignalMixin.wr_dats: acknowledge that optional fields aren't checked.
The original intention of this code was that get_write_fields would return a list of signal information fields to be saved, and check_sig_cohesion would check that those specified fields matched the actual signal data. However, this did not do what was intended. HeaderMixin.get_write_fields returns a 2-tuple of (rec_write_fields, sig_write_fields), not a list of field names. Therefore, the parameter to check_sig_cohesion never had "checksum" or "init_value" as elements, and therefore, check_sig_cohesion never actually checked the values of these fields when writing a record. Many existing test cases rely on being able to read and write a record as-is (missing fields, incorrect init_values, checksums that are correct mod 2**16 but not equal to the result of calc_checksum); these tests would fail if Record.wrsamp actually required init_value and checksum fields to match as check_sig_cohesion expects. This code should be redesigned, and the test cases probably should be less strict. In the meantime, however, make it clear that this function isn't actually doing what it was pretending to do.
1 parent 3047c17 commit cac2af6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

wfdb/io/_signal.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def wr_dats(self, expanded, write_dir):
142142
# Get all the fields used to write the header
143143
# Assuming this method was called through wrsamp,
144144
# these will have already been checked in wrheader()
145-
write_fields = self.get_write_fields()
145+
_, _ = self.get_write_fields()
146146

147147
if expanded:
148148
# Using list of arrays e_d_signal
@@ -152,8 +152,10 @@ def wr_dats(self, expanded, write_dir):
152152
self.check_field("d_signal")
153153

154154
# Check the cohesion of the d_signal field against the other
155-
# fields used to write the header
156-
self.check_sig_cohesion(write_fields, expanded)
155+
# fields used to write the header. (Note that for historical
156+
# reasons, this doesn't actually check any of the optional
157+
# header fields.)
158+
self.check_sig_cohesion([], expanded)
157159

158160
# Write each of the specified dat files
159161
self.wr_dat_files(expanded=expanded, write_dir=write_dir)

0 commit comments

Comments
 (0)