Skip to content

Remove temporary writer parity implementations - #898

Merged
tompollard merged 1 commit into
mainfrom
refactor/remove-legacy-writer-comparisons
Dec 3, 2026
Merged

tompollard merged 1 commit into
mainfrom
refactor/remove-legacy-writer-comparisons

Conversation

@tompollard

Copy link
Copy Markdown
Member

Summary

Remove the temporary old-versus-new writer implementations and parity test used during #866. Public Record and MultiRecord writing methods remain. Direct Record.wr_dat_files calls still use their existing field-based path; its private helper has a descriptive name.

Before deleting the comparison path, its last run passed 374 cases and skipped 44 known unreadable sample records. I added fixed-byte fixtures generated with the v5.17.0 tag for Record.wrsamp with calculated physical calibration, expanded digital channels with different samples per frame, and a byte offset, plus a fixed-layout MultiRecord.wrsamp case. These join the existing modern writer fixtures.

Coverage retained after removing test_header_encoder_parity.py

Deleted comparison cases Retained check
Sample corpus bytes Representative fixed bytes in test_writer_byte_fixtures.py; the full corpus comparison ran before removal and will be repeated independently against main during review. The full corpus matrix is not a permanent fixture.
Record line details record_line_details fixture
Masked mixed formats masked_mixed_formats fixture
Physical writer with explicit and inferred calibration calculated_calibration, record_inferred_format, and new legacy_physical_calibration fixtures
All .dat formats, uniform and expanded format_32, format_508, format_516, and format_524 fixtures in both layouts; existing test_record.py format round trips cover the other writable formats
Expanded mixed formats and masks expanded_mixed_spf, masked_mixed_formats, and new legacy_expanded_digital fixtures
Byte offset New legacy_byte_offset fixture
Declared checksums Equivalent and stale checksum fixtures, plus test_invalid_checksum_declarations_leave_no_files
Modern writer avoids Record.calc_checksum test_write_model_boundaries.py::test_modern_write_does_not_call_record_checksum_method
Full flattened multi-segment writes flattened_multisegment fixed-byte fixture and test_signal_roundtrip.py::test_write_flattened_multisegment_view; full-length corpus comparisons remain a review check
Selected skewed writes and short raw-skew error raw_skew and aligned_skew fixtures, test_signal_roundtrip.py::test_write_full_raw_skew_view, and the required/declared alignment tests
write_record avoids a Record adapter test_write_model_boundaries.py::test_write_record_does_not_create_a_record_adapter
SignalRead.write byte comparisons (selected and masked) masked_mixed_formats, raw_skew, aligned_skew, and archive fixtures, plus test_signal_roundtrip.py
SignalRead.write avoids Record.wrsamp test_write_model_boundaries.py::test_signal_read_write_does_not_call_record_writer
write_signals avoids constructing Record test_write_model_boundaries.py::test_write_signals_does_not_construct_a_record
Multi-segment masters (fixed, variable, incomplete layout) New legacy_fixed_master fixture and existing variable_master fixture; full sample matrix remains a review check
Invalid single- and multi-segment header errors test_writer_byte_fixtures.py::test_invalid_header_errors_match_5_17_0

The fixtures compare complete header and signal-file bytes. The archive fixture compares member bytes because ZIP timestamps may vary. No user-visible writer behavior is changed, so there is no changelog entry.

Checks

  • Old comparison test before deletion: 374 passed, 44 skipped.
  • Fixed-byte fixtures and writer boundary tests: 44 passed.
  • Full offline suite: 1,932 passed, 4 skipped, 23 network tests deselected.
  • Ruff check and format: passed.
  • Sphinx HTML build with warnings treated as errors: passed.

Part of #866. After this lands, I will benchmark all three writers against 5.17.0, then write up the #744/#749 result-type and channel-metadata decision. The parallel-list change is deferred to that decision.

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the temporary comparison code cleanly: 1,299 lines out, 187 in. The fixture map covers what the parity test protected, and it can merge. As promised in the map, I ran the independent comparison against main (76468a3) once more, since this is the last point where the old side still exists. Everything matches. The fixture and boundary tests pass (44 passed), as do the offline suite (1,932 passed, 4 skipped), Ruff and the warnings-as-errors docs build.

What I checked

  • All 26 fixture cases come from 5.17.0. I checked out the v5.17.0 tag, copied in this branch's fixture test, and regenerated every case into a temporary folder. All files and bytes match the checked-in fixtures, including the four new legacy_* cases (Record.wrsamp with calculated physical calibration, expanded digital channels with different samples per frame, a byte offset, and the fixed-layout MultiRecord.wrsamp master with its segments).

  • Nothing still uses the removed code. The only _legacy names left in src/ are unrelated public names (deprecated_legacy_name, to_legacy_record). In tests/, the only ones are the fixture generator functions.

  • The modern writers match main:

    • every readable sample header through write_record and SignalRead.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.

    All file names, bytes and errors are identical.

  • The public Record methods match main. I ran rdrecord(..., m2s=True).wrsamp() and rdheader(...).wrheader() on every sample header, plus wrheader, wrsamp, check_field_cohesion and check_sig_cohesion on 3,000 malformed Records. All 12,440 outcomes are identical, including error messages, printed diagnostics, files left behind and the record's state afterwards. This includes the n_sig=None cases fixed in #897.

  • Inputs are unchanged. My 1,464-write SignalRead.write check still shows no changed arrays, masks or retained fields, with the same 232 expected errors.

Minor, non-blocking

In the map, the "All .dat formats" row relies on test_record.py round trips for formats 80, 212, 16 and 24 in expanded layout. Those check values, not bytes. Each of those formats does have a uniform byte fixture (record_inferred_format, masked_mixed_formats and calculated_calibration), and 16 and 212 also have expanded ones. If you want every format pinned in both layouts, format_80_expanded and format_24_expanded cases would complete it. They'd need generating from v5.17.0, like the others. That's optional, since the per-format encoder isn't part of #866.

With this, the writer refactor in #866 is done apart from the benchmark against 5.17.0 and the #744/#749 decision.

@tompollard

Copy link
Copy Markdown
Member Author

Thanks for rerunning the independent comparisons, particularly the public Record methods and all 26 fixtures against 5.17.0. That gives me confidence the temporary paths can go.

I agree the expanded 80 and 24 byte fixtures would complete the format-by-layout matrix. The PR map distinguishes the existing value round trips from fixed-byte coverage, and this change does not touch the per-format encoder, so I'll leave those optional fixtures for a change that needs that extra byte-level guard. All CI checks are green, and #898 is ready to merge. After it lands, I'll run the writer benchmark against 5.17.0 and write up the #744/#749 decision, including why the parallel-list redesign was deferred.

@tompollard
tompollard merged commit aa227d5 into main Dec 3, 2026
19 checks passed
@tompollard
tompollard deleted the refactor/remove-legacy-writer-comparisons branch December 3, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant