Repository navigation
Sum whole signals at once in _checksums - #676
Merged
Merged
Conversation
Summing a C-ordered signal column by column is several times slower for records with many channels, and a 1-D array returned one value per sample instead of raising an error. Go back to a single reduction along axis 0. read_edf is the only caller with float samples, where the order of the additions can change the result, so it keeps summing each channel separately.
tompollard
commented
Nov 24, 2026
tompollard
left a comment
Member
Author
There was a problem hiding this comment.
Reviewed commit 02de0d7. I found no issues. The integer checksum reduction preserves the prior per-channel result, while read_edf retains separate channel summation for float signals. The 6 focused checksum tests and 39 converter tests pass. CI has no failures so far, with some matrix jobs still running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A small follow-up to #653.
_checksumssums each column in a Python loop, which has two side effects forcalc_checksum:axis=0(this PR)d_signalTypeError[0, 1, 2, ...]The loop is faster for records with few channels, but several times slower for recordings with many channels. The absolute cost is small either way. The more important difference is that a 1-D array returns one value per sample instead of raising an error.
_checksumsgoes back to a single reduction along axis 0, which is whatcalc_checksumandwfdb_to_matused before #653. For integer samples the result is the same either way.read_edfis the only caller with float samples, where the order of the additions can change the truncated result (ten values of 0.1 sum to 1.0 by column, and to 0.9999999999999999 along axis 0). It keeps summing each channel separately, so its checksums don't change.Testing:
test_checksums_rejects_1dis restored.test_float_checksumreads a small two-channel EDF file and checks the checksums. It fails ifread_edfuses_checksums.uv run pytest -m "not network" -W errorpasses (566), as doruff format --checkandruff check.No changelog entry, since #653 is not released and behaviour is the same as in the last release.
@tompollard 🟥 red 🐳 whale · quince