Skip to content

Compute float bin centres without overflowing near the float64 limits - #76

Merged
guijacquemet merged 1 commit into
mainfrom
claude/bin-centre-overflow-75
Nov 7, 2026
Merged

guijacquemet merged 1 commit into
mainfrom
claude/bin-centre-overflow-75

Conversation

@guijacquemet

Copy link
Copy Markdown
Contributor

Fixes #75

PlaneHistogram.representatives formed lo + half_range * fraction, where the fraction reaches almost 2, so the product overflowed to inf for pixels near +-float64 max although the centre is representable. The arithmetic moves to float_bin_centres (new pure module bin_centres.py): only bins whose plain result is non-finite are recomputed from the midpoint; all other bins keep the original arithmetic. (Moved out of histogram.py because its length baseline is shrink-only.)

End-to-end test in tests/test_pooling.py: pixels at -/+limit -> compute_plane_histogram -> PooledHistogram -> linear_percentile/percentile at q = 0/25/50/75/100, against an exact fractions reference. The float64-max cases fail on main (5 failures) and pass here.

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

Gate: python tools/check.py 659 passed, 2 skipped (csbdeep not installed, tests/test_rgb.py:78), code rules clean.


Generated by Claude Code

@guijacquemet
guijacquemet marked this pull request as ready for review November 7, 2026 00:19
@guijacquemet
guijacquemet merged commit 3b5378a into main Nov 7, 2026
8 checks passed
@guijacquemet
guijacquemet deleted the claude/bin-centre-overflow-75 branch November 7, 2026 00:19
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.

Histogram bin centres overflow for pixels near the float64 limit

2 participants