Repository navigation
Prevent double-precision underflow in findEmpties for deep empty regions (#8108) - #8162
Open
davrens101 wants to merge 2 commits into
Open
davrens101 wants to merge 2 commits into
davrens101 wants to merge 2 commits into
Conversation
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.
Prevent double-precision underflow in findEmpties for deep empty regions
Fixes #8108.
Root cause
In
src/traces/heatmap/find_empties.js, empty (NaN / undefined) grid cells are flood-filled in layers to compute a distance/interpolation weight forcontour,heatmap(withconnectgaps: true),surface, andcontourcarpet. In each layer, the cell weight decays geometrically by dividing by 20:When an empty region is deeper than ~249 layers along the propagation path, the geometric decay
(1 / 20)^249falls belowNumber.MIN_VALUE(≈ 4.94e-324, the smallest positive IEEE 754 float64). The quotient underflows to exactly0. Consequently:if(neighborCount)evaluates tofalseeven though the cell has valid non-zero neighbors.foundNewNeighbors = false.'findEmpties iterated with no new neighbors', crashing the plot.Solution
if(neighborSum)instead of the divided quotient to check if neighbors exist.neighborSum > 0butneighborSum / 20underflows to 0 in float64, clampneighborCounttoNumber.MIN_VALUE.Verification
Added unit test
should fill deep empty regions without floating-point underflow (#8108)intest/jasmine/tests/heatmap_test.jswith a 5x250 empty strip (depth 250).Pre-fix result: Failed with
Error: Expected function not to throw, but it threw 'findEmpties iterated with no new neighbors'.Test passes cleanly (
51 of 51 SUCCESSinheatmap_test.js).All
contour_test.jstests pass cleanly (27 of 27 SUCCESS).Biome linter passes across the repository with 0 warnings/errors (
Checked 2641 files in 1310ms. No fixes applied.).Review and disclosure
AI assisted in investigating the root cause, developing the minimal clamp fix, and writing the regression test. Verified locally with Jasmine/Karma headless Chrome test runs and Biome lint.