Repository navigation
Reject shortened raw skew reads before writing - #846
Conversation
tompollard
left a comment
There was a problem hiding this comment.
Thanks. On main, writing the first 100 frames of 100skew read with ignore_skew=True reads back with -2048 in the last three frames of channel 1 (the source has 985, 987, 987), so rejecting it is right. A raw read that runs to the end (start=649000) still writes and reads back identically, and ignore_skew=True reads of headers without a signal length still work, including a skewed one, where the flag is set correctly. The offline suite, Ruff and the strict docs build pass locally.
A possible follow-up rather than a change here: the reader could include the extra max(skew) samples after stop for an ignore_skew=True read, which would make short raw reads writable instead of rejected.
Ready to merge once CI is green.
|
Thanks for checking the reproducer and the edge cases. I agree that reading the extra tail samples could eventually let us write a shortened raw view while preserving its alignment. We would need to define how those extra samples relate to the requested The CI jobs have passed except for the macOS Python 3.15 job, which is still running. |
## Summary - Capture the per-channel fields once before calculating header defaults, so defaults and the subsequent write use the same current channel values. - Validate channel list types and lengths before applying defaults. Invalid lists now fail without leaving a partially defaulted record. - Keep the existing mutable `Record` lists as the source of truth; supplied lists retain their identity and partial lists are not filled in. This is a small step toward #749 and #744. It does not change the public record model. ## Verification - Offline suite: 1,650 passed, 4 skipped, 23 deselected. - Ruff format and lint checks passed. - Strict Sphinx docs build passed. - Compared six representative generated headers against `main`; all were byte-identical. This PR is independent of #846.
Summary
A shortened
ignore_skew=Trueread includes only the requested raw frames.If a selected channel has positive skew, writing those frames with the source
skew loses aligned values at the end of the view. Both
Record.write()andRecord.wrsamp()now reject that write before creating files. The same checkapplies through
SignalRead.write().The read records whether its stop is before the source record's end and a
selected channel has nonzero skew. That small private flag survives copying
and pickling. Full raw reads, selected channels without skew, and short reads
whose skew is deliberately cleared remain writable. The legacy test that
previously accepted a short raw skewed
SignalRead.write()is updated toexpect the early error; a full-length raw write is still tested.
This addresses the selected-read tail case noted on #843. The separate
question of how to declare the alignment of an arbitrary replacement array
remains open there.
Validation