Repository navigation
Extract flattened write preparation from Record - #891
Conversation
|
The failing check was the docs build. Its docs-only environment mocks NumPy, I deferred that annotation's evaluation in 2510aa0. I reran the docs-only |
tompollard
left a comment
There was a problem hiding this comment.
The extraction is correct, output is unchanged, and it can merge. 2510aa0 fixes the docs failure: the warnings-as-errors docs build passes locally with NumPy mocked, and all 19 CI checks pass.
What I checked
-
The helper keeps every branch of
_prepare_flattened_write:- units default to
"NU"; - format 32 is used when formats are incomplete or a file mixes formats;
- for physical values, the format 32 fallback is followed by calculated calibration;
- for digital values, the old marker (or the dtype minimum when the format is unknown) is recoded to format 32's marker on an
int64copy; - missing gains and baselines are filled with 1.0 and 0.
_WriteModelno longer bindsRecord._prepare_flattened_write. - units default to
-
Flattened output is byte-identical to
mainacross all writers. Because the helper is shared, the parity test can't check it, so I compared this branch withmain(87ba3c3) directly. That covered six masters (041s,v102s, boths00001records,s25047, andp000878), five windows including full length, both kinds and layouts, and four writers:write_record,SignalRead.writewith inferred formats and withformats="32", and the legacyrdrecord(..., m2s=True).wrsamp. All 480 cases match: 258 writes with identical file names and bytes, and 222 identical errors. The annotation fix in 2510aa0 doesn't change behaviour. -
The flattened-preparation and fixture tests pass (39 passed), as do the offline suite (2,284 passed, 48 skipped) and Ruff.
Minor
As with #890, failure is now cleaner. The old method set self.units (with None replaced by "NU") before raising "No signal values are available for this layout", so a failed Record.wrsamp left units changed. The helper raises before anything is applied. That's an improvement and needs no changelog entry.
Summary
Continue #866 after #890 by moving flattened multi-segment write preparation
out of
Record._prepare_flattened_write.and arrays explicitly. It preserves the format-32 fallback and translates
missing-sample markers when digital channels need a common format.
Record.wrsamppath retains its private wrapper. Themodern
_WriteModelcalls the shared helper directly and no longer borrowsRecord._prepare_flattened_write.physical fallback calibration, and the model's independence from the Record
method.
The helper is shared by both write paths, so the differential test alone
cannot catch a mistake inside it. I also compared this branch with the
pre-change main checkout (
87ba3c3) across 24 flattened write cases fromfive sample masters, both kinds and layouts, plus a full-length
041sread.All 12 successful cases produced the same file names and bytes; the other 12
failed with the same exception type and message. The fixed 5.17.0 flattened
fixture also passes. No public behavior change is intended.
Checks