Repository navigation
Write model signal files from explicit arrays - #896
Conversation
tompollard
left a comment
There was a problem hiding this comment.
The .dat step is correct, and it can merge. It has the same follow-up as #895. The focused .dat, fixture, parity and warning tests pass (416 passed, 44 expected skips), as do the offline suite (2,294 passed, 48 skipped) and Ruff.
What I checked
-
_check_dat_valuesmatches the checks the model path actually ran. You're right thatwr_datspasses an emptywrite_fieldslist, so only the shape and range branches ofcheck_sig_cohesionran. The new function repeats those branches exactly: the same expanded length check withsamps_per_frame or 1, the same uniform shape check with itsprints and message, and the same per-channel_digi_boundscheck raisingIndexErrorwith the same text. The only change is that the channel count comes from the header snapshot instead ofself.n_sig, and the header step has already validated that they agree. -
Output compared directly with
main(fa5f324). As for #895, every modern write now goes through new code:- every readable sample header, both kinds and layouts, through
write_recordandSignalRead.write; - 3,000 random sparse records through
write_record; - the 15 invalid header-field cases;
- the 480 flattened multi-segment writes across all four writers.
Every outcome matches
main, file names, bytes and errors included. - every readable sample header, both kinds and layouts, through
-
Inputs are unchanged. My 1,464-write
SignalRead.writecheck still shows no changed arrays, masks or retained fields, with the same 232 expected errors asmain. -
The new test fails on
main, which I checked by copying it into amaincheckout. -
Performance is unchanged. On
100skew(write only), all five writer and kind combinations are within noise ofmain, with identical peak memory.
Follow-up for the cleanup PR, as on #895
_check_dat_values now repeats the shape and range branches of SignalMixin.check_sig_cohesion, which Record.wrsamp still uses through wr_dats. With this and #895, the model no longer calls the inherited header or .dat writers. So the cleanup PR can:
- make
Record._write_checked_header,check_field_cohesion's snapshot branch andcheck_sig_cohesion's shape and range branches call the new module functions, while the parity test can still confirm theRecordside; - drop the mixin inheritance from
_WriteModel; - remove the
_legacy_*paths, with the checklist mapping each parity test to its replacement.
## Summary Consolidate the duplicate header and signal validation left by #895 and #896. `Record._write_checked_header` now calls the explicit header function, its snapshot cohesion check calls the shared helper, and `SignalMixin.check_sig_cohesion` uses the explicit shape and range checker while keeping its direct-call checksum and initial-value checks. `_WriteModel` no longer inherits `BaseRecord`, `HeaderMixin`, or `SignalMixin`. This is the first #866 cleanup step. The `_legacy_*` paths and parity test remain independent for this review. Removing them needs a separate checklist that maps each parity case to a fixed byte fixture or test. The model still projects channel fields to lists while preparing a write; that remaining metadata representation work is separate from inheritance removal. ## Checks - 2,294 offline tests passed; 48 skipped and 23 network tests deselected. - Writer byte fixtures, old-versus-new parity, explicit header and `.dat` tests, and warning caller tests passed (417 passed, 44 expected skips in the focused run). - Direct `Record.check_sig_cohesion` calls matched pre-change main in 2,000 generated cases, including errors, printed diagnostics, and in-place samples-per-frame defaults. - Docs built with warnings treated as errors; Ruff and `git diff --check` passed. No changelog entry because this changes only internal writer structure.
Summary
Write
_WriteModelsignal files from the header's channel snapshot and explicit digital arrays. The model path now validates the digital field, shape, and per-channel format bounds, then calls the existing_write_dat_filesencoder directly. It no longer calls inheritedSignalMixin.wr_dats,check_sig_cohesion, orwr_dat_files.This is the
.datstep of #866. The publicRecordmethods and the old comparison path remain in place. No public behavior or file output change is intended.The old
wr_datscall passes an emptywrite_fieldslist tocheck_sig_cohesion, so its checksum and initial-value branches do not run on this path. Those branches remain in the legacy method; this PR extracts the checks that the model actually uses.Checks
SignalMixin.check_sig_cohesionmethod in 1,000 generated valid and invalid cases.git diff --checkpassed.No changelog entry because this changes only the internal writer path.