Skip to content

Use signal_alignment on modern readers - #854

Merged
tompollard merged 1 commit into
mainfrom
modern/read-signal-alignment
Dec 2, 2026
Merged

tompollard merged 1 commit into
mainfrom
modern/read-signal-alignment

Conversation

@tompollard

@tompollard tompollard commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Use signal_alignment="aligned" | "raw" on read_record and read_signals in place of ignore_skew. The default remains aligned; "raw" retains the stored skew, equivalent to the old ignore_skew=True. Legacy rdrecord keeps its existing parameter.

This deliberately changes the recently released modern reader signatures so reads and writes use the same words. The migration guide, API docs, and changelog explain the change. The migration guide also notes that newer signatures are still being refined before the next major release.

Tests compare aligned and raw results with the legacy reader, reject invalid values and the removed modern keyword, and update the skew write tests to use the new read option.

Part of #852. Rebases on main after #851 and #853.

Verification

  • Offline suite: 1,715 passed, 4 skipped (bxb unavailable), 23 network tests deselected
  • Ruff check and format check: passed
  • Sphinx HTML build with warnings as errors: passed

@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.

The new wording works and changes nothing about the values. I compared 704 reads on this branch with main (all of sample-data, both layouts, read_record and read_signals). signal_alignment="aligned" matches the old default and "raw" matches ignore_skew=True in every case: same values and same record fields. Invalid values and the removed ignore_skew keyword are rejected. The offline suite (1,717 passed, 4 skipped), Ruff and the strict docs build pass locally. CI hasn't run because the PR targets the #851 branch, so it will run after the retarget.

What I checked

  • The user-facing error messages that mentioned ignore_skew=True now describe a raw read, including the tail-sample error. Remaining ignore_skew mentions in src are internal arguments or the legacy rdrecord and wrsamp docstrings, which is correct.
  • The provisional-API note in docs/migration.rst covers the last part of #852. Naming the release where the newer names become stable, for example "until 6.0", would make it more concrete for users. That's optional.

Suggestions

  • Record the alignment used for the read. Since #851 requires the choice when writing, a SignalRead or Record from a raw read still makes the caller restate "raw". Exposing the read's choice on the read result, for example source_selection.signal_alignment, would let callers pass it on deliberately. It would also give the docs an example that doesn't depend on remembering how the data was read. This could be a follow-up.
  • Remaining inconsistency from #852. read_signals still requires layout, while read_record defaults it to "uniform". This could go in this PR, since it's the same kind of signature cleanup, or in a follow-up.
  • iter_dataframes keeps ignore_skew, along with its other legacy names. See my comment on #853. It needs a decision in #852 rather than a change here.

Merge order

This conflicts with #853 in read_signals and in tests/test_read_record.py. The conflicts are small, but if #853 merges first, the rebase onto main after #851 will need to resolve them.

@tompollard

Copy link
Copy Markdown
Member Author

I rebased this branch onto the updated #851 branch and resolved the docstring and test conflicts. The affected 122 tests, Ruff, and the warning-strict docs build pass.

I would keep the write choice explicit after a read. source_selection describes the original source coordinates; an original read-alignment field there could become stale after in-place edits to the NumPy values. Exposing it as read provenance may still be useful in the metadata redesign, but it should not be treated as the alignment of the current arrays.

I agree that the layout difference deserves a decision soon. My preference is to require it on read_record too, so multi-frequency smoothing is never implicit in a newer read. I would do that in a focused PR before the next release because it changes many call sites; #852 tracks it. I would also avoid promising stability specifically at 6.0 until we settle the data-model and legacy-removal decisions. I filed the chunked-reader signature gap as #856.

@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.

Thanks. The rebase onto the updated #851 looks right. The new skew error ends with "as from signal_alignment='raw' on a read" after the per-channel list. The offline suite (1,717 passed, 4 skipped), Ruff and the strict docs build pass locally.

I agree with the replies:

  • Read alignment. Fair point: a field describing the original read could look like the alignment of arrays that have since been edited in place. Keeping the write choice explicit, and considering read history in the metadata redesign, is the safer order.
  • layout. Requiring it on read_record too, so smoothing is never implicit, is a good resolution. A separate PR makes sense given how many call sites it touches.
  • 6.0. Agreed. It's better not to name a version until the data-model and legacy-removal decisions are made.

As planned, this branch still conflicts with #853 in read_signals and tests/test_read_record.py (I checked by merging #851 and #853 onto main first). It will need the rebase once those two are in, and CI will run after it is retargeted to main. Then it is ready to merge.

Base automatically changed from fix/require-explicit-skew-alignment to main December 2, 2026 15:39
@tompollard
tompollard force-pushed the modern/read-signal-alignment branch from 81dd923 to 8431519 Compare December 2, 2026 15:41
@tompollard
tompollard merged commit da79f6e into main Dec 2, 2026
19 checks passed
@tompollard
tompollard deleted the modern/read-signal-alignment branch December 2, 2026 15:42
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