Repository navigation
Add n_frames alias for record frame count - #808
Conversation
tompollard
left a comment
There was a problem hiding this comment.
Thanks. n_frames fits well: one stored value with sig_len, the same validation as n_signals (strings, floats, booleans and negatives rejected; np.int64 stored as int), and the name matches read_header and metadata and counts frames rather than expanded samples. To check the new write-time frame check for false positives, I wrote every single-segment sample record in all four forms with full, partial and ignore_skew reads (984 combinations), and main and this branch gave identical results. Real mismatches are caught: trimming p_signal to 3 rows gives sig_len (n_frames) is 4, but p_signal has 3 frames, updating n_frames to 3 writes a valid header, and shortened expanded channels are caught per channel. The offline suite, Ruff and the strict docs build pass locally.
Not for this PR: the legacy wrsamp prints sig_len, n_sig and the array shape to stdout before raising sig_len and n_sig do not match shape of d_signal. Folding those values into the message would be a small follow-up.
Ready to merge once CI is green.
Summary
Add
n_framesas a mutable alias forsig_lenonRecordandMultiRecord, including a keyword-only constructor argument. The two names share one stored value. Assignment through the new name accepts non-negative integers orNone, following then_signalspattern.sig_lencounts base sample frames. An expanded channel can have more samples than frames, son_framesdescribes this value more precisely than the provisionalsignal_lengthname in #672. The name also matchesread_headerandRecord.metadata.While testing this alias, I found that
write_recordsilently recalculated an editedsig_lenfrom the array. It now checks a declared frame count against the selected uniform or expanded values before writing. When the count is unset, it still derives it on a copy of the record. Tests cover both record classes, expanded values, selections, serialization, invalid inputs, and writer behavior.Related to #672 and #744.
Verification