Repository navigation
Use NumPy for the digital range check in check_sig_cohesion - #610
Merged
Merged
Conversation
tompollard
reviewed
Oct 31, 2026
tompollard
left a comment
Member
There was a problem hiding this comment.
Thanks, this looks good, and it's nice to have tests for this check now! For a 1-hour, 8-channel record the check went from 0.61 s to 0.02 s on my machine.
TheNetherWatcher
force-pushed
the
faster-sig-cohesion
branch
2 times, most recently
from
October 31, 2026 18:42
fc3e22d to
1b20ac2
Compare
The minimum and maximum of each channel were found with Python's built-in min and max, which iterate over the array one element at a time. This took about 85% of the time of wrsamp for large records. Use np.min and np.max instead.
TheNetherWatcher
force-pushed
the
faster-sig-cohesion
branch
from
October 31, 2026 18:49
1b20ac2 to
fe6ef44
Compare
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.
check_sig_cohesionfinds the minimum and maximum of each channel to check that the digital samples fit the format. It used Python's built-inminandmax, which go through a NumPy array one element at a time, so this check took about 85% of the time ofwrsampfor large records. This usesnp.minandnp.maxinstead, in both the single-frequency and the expanded (multi-frequency) path.Time for a 4-hour, 8-channel record at 500 Hz (57.6 million samples), written from digital samples:
The written files are unchanged. There were no tests for this check, so I added
TestSigCohesion: a value just outside the range in the last sample is rejected (in both paths), and the smallest and largest values of each format are allowed. These pass onmainas well, and fail if the check skips the last sample.Related: #607 speeds up the byte packing in the same
wrsampcall. The two don't touch the same lines, apart from both adding a changelog entry and a test class at the end of the file.pytest -m "not network"passes (101 tests), and the docs build passes.