Skip to content

Use start and stop in multi-segment read errors - #912

Merged
tompollard merged 2 commits into
mainfrom
fix/read-signals-range-errors
Dec 4, 2026
Merged

tompollard merged 2 commits into
mainfrom
fix/read-signals-range-errors

Conversation

@tompollard

@tompollard tompollard commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #907. read_signals now translates legacy sampfrom/sampto wording to its public start/stop names for invalid windows on multi-segment records. A shared helper keeps the modern read_signals and read_record messages aligned with read_segments, including accurate wording that stop may equal the record length. Empty records keep their existing error. This is separate from the format-8 decoding fix in #911.

Checks

  • Seven regression cases cover read_signals, read_record, and read_segments, checking both invalid bounds on single- and multi-segment records.
  • Full offline suite: 2,140 passed, 4 skipped.
  • Ruff lint and formatting pass.

@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 fixes #907 as described, and it can merge. I have two small suggestions, neither blocking. The offline suite (2,137 passed, 4 skipped), Ruff and CI pass, and it merges cleanly with #911.

What I checked

On main (a8ad0c4) and on this branch, I compared the errors from read_signals, read_record and read_segments for nine invalid windows:

  • start equal to or past the length;
  • stop past the length;
  • negative start and stop;
  • empty and reversed windows;
  • non-integer start and stop.

I ran these on 100, v102s and s25047. The only changes are the six multi-segment read_signals messages that used sampfrom/sampto. Every other message is identical, and no message mentions the legacy names any more.

Suggestions

  1. The three readers still word the same mistakes differently. For v102s:

    Input read_signals / read_record read_segments
    start=225000 stop must be greater than start start must be shorter than the record length
    stop=225001 stop must be shorter than the signal length stop must not exceed the record length

    "stop must be shorter than the signal length" is also slightly wrong, since stop may equal the length. read_segments' "must not exceed the record length" is the accurate wording. Using one set of messages for all three modern readers would finish what #907 was after.

  2. The rewrite now exists three times in record.py (lines 3688, 3856 and 3886), each matching message prefixes and replacing text. A small helper would remove the copies. Better still, _check_read_inputs could take the argument names to use, so the modern readers never produce sampfrom/sampto in the first place. The legacy Record.check_read_inputs could keep passing its own names. Then the wording fix in suggestion 1 would need changing in only one place.

@tompollard

Copy link
Copy Markdown
Member Author

Thanks, both suggestions improve this PR. In 198e15e I moved the legacy-to-modern range translation into one helper and aligned read_signals and read_record with read_segments: start must be shorter than the record length, and stop must not exceed it. I kept the existing “stop must be greater than start” message for an empty record, where there is no readable frame.

I kept the legacy validator's own wording unchanged so rdrecord is unaffected. The new tests cover all three modern readers; the full offline suite passes (2,140 passed, 4 skipped), as do Ruff and the docs build.

@tompollard
tompollard merged commit ceb13f2 into main Dec 4, 2026
19 checks passed
@tompollard
tompollard deleted the fix/read-signals-range-errors branch December 4, 2026 17:36
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.

Use start and stop in multi-segment read_signals range errors

1 participant