Skip to content

Interpolate percentiles between finite extremes without overflowing the gap - #74

Merged
guijacquemet merged 1 commit into
mainfrom
claude/interpolation-overflow-32
Nov 7, 2026
Merged

guijacquemet merged 1 commit into
mainfrom
claude/interpolation-overflow-32

Conversation

@guijacquemet

Copy link
Copy Markdown
Contributor

Fixes #32

_linear_percentile formed above - below, which overflows to inf for finite endpoints further apart than float64 (e.g. -1e308 and 1e308), giving inf/NaN where the interpolation is representable. The arithmetic now moves into _lerp: only when the gap overflows and both endpoints are finite does it interpolate from the halved endpoints; every other input keeps NumPy's arithmetic unchanged. Non-finite endpoints behave as before (#70/#72 cover the tails).

Note: building a histogram from such pixels still overflows bin centres in histogram.py; that is outside this issue, so the regression test calls _linear_percentile directly with q = 0/25/50/75/100 against an exact fractions reference. It fails on main (12 failures) and passes here.

Bitwise: tools/dump_outputs.py SHA-256 identical on main (5848efc) and this branch: dfd5e740e04e16057bc6a017e844ae62cb94025690531b443a9489f52900537e.

Gate: python tools/check.py 649 passed, 2 skipped (csbdeep not installed, tests/test_rgb.py:78), code rules clean; baseline shrank by one entry (_linear_percentile length).


Generated by Claude Code

…he gap

Fixes #32

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbytvF3Gsa85ix8Ne2yMDW
@guijacquemet
guijacquemet marked this pull request as ready for review November 7, 2026 00:06
@guijacquemet
guijacquemet merged commit 3d35529 into main Nov 7, 2026
8 checks passed
@guijacquemet
guijacquemet deleted the claude/interpolation-overflow-32 branch November 7, 2026 00:06
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.

[Sad Catapella N2][Numerical correctness] Linear interpolation percentile overflows between finite extreme values

2 participants