Repository navigation
Make loaded single-segment signal modes explicit - #756
Conversation
tompollard
left a comment
There was a problem hiding this comment.
The new _LoadedSignalValues.set_on_record checks dimensions and dtype, but it does not check that the values match the record's shape. For example, a (3, 1) digital array is accepted when record.n_sig == 2, and an expanded array of 2 samples is accepted when sig_len == 3 and samps_per_frame == [2] require 6. Both leave the Record internally inconsistent even though this helper is described as validating the loaded layout (src/wfdb/io/record.py:2400-2419). Please check the uniform shape against (sig_len, n_sig) and each expanded channel length against its frame count, or narrow the helper's stated validation contract.
I did not reproduce a failure in the current read paths. The full offline suite passed (910 passed, 4 skipped, 21 deselected).
|
Thanks, you're right. I added the missing size checks in b33e49b. Uniform The full offline suite passes: 912 passed, 4 skipped. Ruff checks pass too. |
tompollard
left a comment
There was a problem hiding this comment.
The added size checks address my earlier concern. The two malformed layouts I raised now fail before assignment, and the full offline suite passes (912 passed, 4 skipped, 21 deselected). I found no remaining correctness issue.
One small readability suggestion in _record_from_single_segment_read: the adjacent if read.physical: blocks can be combined so conversion and selection of the physical signal field happen in the same branch. They do different work, so the repetition is not a behavior bug. The current code has only one dac call; the longer call shown in the diff was removed.
|
Thanks, I combined the physical conversion and field selection in the same |
## Summary Use the same private loaded-value mode check for records flattened from multiple segments as for single-segment reads. It checks that the combined values match the physical/digital and uniform/expanded mode and the resulting record shape before assigning the public signal field. This extends #756 toward #745. The `Record` API and output values stay the same. Segment-preserving reads already use the single-segment path for each loaded segment. ## Verification - Added tests for all four flattened modes across a segment boundary. - Offline suite: 916 passed, 4 skipped, 21 deselected (`MPLBACKEND=Agg`). - Ruff check and format check passed.
Summary
Represent the four single-segment read modes explicitly at the boundary where
loaded values are assigned to a
Record: physical or digital, and uniform orexpanded. The private
_LoadedSignalValueschecks the value layout and numerictype, then fills the matching legacy signal field and clears the other three.
Uniform arrays must match
(sig_len, n_sig); expanded channels must havesig_len * samps_per_framesamples.The existing in-place digital-to-physical conversion remains in use, so this
does not add a second full signal array during conversion. Public
Recordfields and read options stay the same. This is an initial internal step for
#745, not a new public signal API.
Verification
shapes, dtypes, and which public field is populated.
expanded physical reads.
MPLBACKEND=Agg).check passed.