Repository navigation
Add samples_per_frame alias to Record - #809
Conversation
tompollard
left a comment
There was a problem hiding this comment.
Thanks. samples_per_frame matches the name already used by SignalHeader and ExpandedSignals, shares one list with samps_per_frame through copies and pickling, and validates assignments the same way as n_signals and n_frames. I also checked every single-segment sample record (168 header-only and sample reads): all produce plain lists of integers, and assigning each back through the new name works, so the stricter setter won't reject values the readers produce. A wrong multiplier on an expanded write is rejected, and the corrected one round-trips. The offline suite, Ruff and the strict docs build pass locally.
Two optional notes:
- On a uniform read of
test01_00s_frame,samples_per_frameis[1, 2, 1]whilep_signalhas one value per frame, and a uniform write stores[1, 1, 1]. The docs explain the expanded case only. A sentence saying that on a uniform record it describes the source file, and that uniform writes store one sample per frame, would avoid confusion. - In-place edits bypass the setter (
record.samples_per_frame[1] = 0is accepted). On an expanded write this surfaces as... expected 0 for samps_per_frame=0, which is correct but indirect. A write-time check that the values are positive would give a clearer message.
Ready to merge.
|
Thanks, I addressed both notes in 9169e49. The docs now explain that a uniform read can retain the source frame layout in Expanded writes now check that each multiplier is positive before calculating expected channel lengths, including after an in-place list edit and when |
Summary
Add
Record.samples_per_frameas a mutable alias for the existing per-channelsamps_per_framelist. TheRecordconstructor accepts either spelling and rejects both together. The new spelling acceptsNoneor a list of positive integers, while direct assignment to the established field keeps its behavior. Both names refer to one stored list, including after reads, copies, and pickling.The docs explain that expanded channel
icontainsn_frames * samples_per_frame[i]values. The alias works with channel selection and writing; the tests include an invalid edited multiplier that the writer rejects and a valid round trip.MultiRecordhas no top-level per-channel list, so this PR leaves its signal metadata design to #441.On a uniform read, the list can still describe the source file's frame layout even though the loaded array has one value per channel per frame. A uniform write stores one sample per frame for each channel. Expanded writes now validate every multiplier at write time, including after in-place list edits.
Related to #672 and #744.
Verification