Repository navigation
Keep source headers separate during single-segment reads - #754
Conversation
There was a problem hiding this comment.
I found one design and test concern, not a reproduced output regression.
_rdrecord materializes a mutable Record from source_header before validation and signal reading (src/wfdb/io/record.py:2725-2728), then _record_from_single_segment_read materializes a second Record from that same header after the read (:2821-2832). Any derived field changed on the first object must be copied into the parsed header for the returned object; sig_len already needs this explicit synchronization (:2732-2739). That leaves two states to keep aligned as the read path evolves. Please consider keeping one materialized read record while retaining the parsed source separately, or make the transfer of derived fields explicit in one place.
The new test_selected_records_do_not_change_the_source_header calls _record_from_single_segment_read with synthetic values. It does not exercise the _rdrecord handoff or its cache. Add an integration test that makes two _rdrecord calls with the same header_cache, edits the first returned record, and checks the second record and cached parsed fields. I ran that scenario manually and it currently passes; the request is to guard the path this PR changes.
The affected offline tests passed (276 passed, 14 deselected). I did not find a current user-visible regression.
|
Thanks for the careful review. Addressed both points in de28bc2.
I replaced the synthetic test with an integration test that calls |
Summary
Carry the parsed source header through single-segment reads. A header-only
Recordis materialized once for validation and reading, then that same objectbecomes the selected public result. A private read result keeps the parsed
source fields, selected samples, channel selection, and read options together
while the result is built.
Header-only reads, multi-segment reads,
.wfdbarchives, and DataFrame chunksuse the same parsed-header loader and materialize independent
RecordorMultiRecordobjects. The iterator cache now holds parsed fields, so editing areturned record cannot alter source metadata for later windows.
This is the first internal step for #743. It makes no public API or output
change and adds no second mutable metadata object to
Record.Verification
edits the first returned record, and verifies the second result and cached
parsed fields remain unchanged.
MPLBACKEND=Agg).