Repository navigation
Preserve small differences in large integer local-peak inputs - #732
Merged
tompollard merged 3 commits intoNov 25, 2026
Merged
Conversation
Refactor peak detection to handle flat mountain scenarios and improve dtype handling.
Add tests for local peak detection with large integers and small values.
The change adds a new entry to the changelog detailing improvements in handling local peaks for large integer inputs.
tompollard
approved these changes
Nov 25, 2026
tompollard
left a comment
Member
There was a problem hiding this comment.
I reviewed the large-integer fallback and its regression tests. It preserves exact peak comparisons while leaving the common fast path unchanged. Looks good to me, thanks again!
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.
Problem
processing.find_local_peakssends integer signals throughscipy.ndimage.maximum_filter1d, which rounds large 64-bit integers internally. Small differences on a large positive or negative offset can disappear, producing false or missing peaks.For example, an
int64signal formed by adding2**60to[0, 1, 0]should retain its single peak at index 1. The same issue affectsuint64values near2**63and negativeint64offsets.Change
Use the existing exact sample-by-sample scanning path when an integer signal contains values outside the exact integer range of a double. Ordinary integer and floating-point inputs retain their existing path. The constant-signal early return is unchanged.
This deliberately trades speed for exact comparisons on those large-integer inputs; no performance improvement is claimed for them. It does not alter the vectorized common-input path introduced in #655 or the separate
find_peaksoverflow fix in #664.Add 18 regression cases spanning positive and negative
int64offsets,uint64, two radii and three signal shapes, including a plateau. Expected peaks come from explicit bounded windows over the small, exact shape values. Four small-value dtype controls and input-immutability checks are included, plus a changelog fragment.Validation
Python 3.12.16, isolated against upstream
98df2c9fba00943004ceac42677744f85a98e702:tests/test_processing.pyandtests/test_hr.py, excluding network tests: 238 passed.-W --keep-going -E) passed.Other private fixes were not included. Full-repository tests, performance benchmarks, other Python/dependency versions and remote CI were not run for this change. Prepared and tested with AI assistance; no independent human review is claimed.