Repository navigation
fix(features): fillnan='nearest' leaves points with a NaN coordinate NaN - #424
Merged
Merged
Conversation
Since #413 a point with a NaN coordinate gives NaN. evaluate_value with fillnan='nearest' then sent those points to the KD-tree query, which raised "'x' must be finite". After #421 the fault-side check of a gradient reaches this path, so evaluate_model_gradient of a model with cutting faults failed. Only points with finite coordinates get the nearest value; a point with a NaN coordinate has no nearest point and stays NaN. A call with no known value also stays NaN. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose
added a commit
that referenced
this pull request
Nov 26, 2026
…ormance #421 changes the gradient near faults: only the tetrahedra that cross a fault are made smaller (at most 10 times), and a point whose tetrahedron still crosses a fault has a NaN gradient. The conflict is in the refinement loop of GeologicalFeature.evaluate_gradient: take the loop of master and keep its fault-side check inside probe_points(). On the 21 golden models the branch gives the same bits as master a942177 for all 97 outputs that master can compute. The other 2 (cutting_faults gradients) fail on master too; #424 fixes that. The golden references and the batch-count tests are updated in the next commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose
added a commit
that referenced
this pull request
Nov 26, 2026
#424 (open against master) stops fillnan='nearest' from sending points with a NaN coordinate to the KD-tree, which made cutting_faults gradients fail after #421. It is the same commit as on the PR branch, so the later master merge has no conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose
added a commit
that referenced
this pull request
Nov 26, 2026
…changed (C-021) Master #421 changes fault gradients near faults, fault_pitch and fold rotation angles. 60 outputs of 17 golden models change (mostly gradients; cutting_faults also some values, restored points and one model id). The new references come from master a942177 with the fix of #424, captured at the stored reference points. Evidence: - the spec 003 branch gives the same bits as that code for all 970 arrays of the 21 golden models; - in each updated model, every array that #421 does not change is bit-identical to the old reference. The manifest records the code, the reason and the changed keys under provenance.reference_updates, with the new sha256 and summaries. The gradient batch tests replay the refinement of #421: only the tetrahedra that cross a fault are made smaller, at most 10 times, and a point whose tetrahedron still crosses a fault is NaN. cutting_faults group_0 now has 29 distinct (fault, batch) calls (25 before #421; the refinement probes the crossing subset at each step) and still no duplicate. A gradient has one scope slot for each probe size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose
added a commit
that referenced
this pull request
Nov 26, 2026
…baseline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose
added a commit
that referenced
this pull request
Nov 26, 2026
The candidate 6c2bbb0 against the Linux baseline (master a942177 with #424, branch bench/003-linux-baseline at 7b4d910), standard suite twice each, tracemalloc memory meter. acceptance.json passes: SC-002 0.098, SC-003 0.122, SC-004 1.09, SC-005 0.216, SC-006 worst 1.215 within the 16 MiB allowance, SC-007 1.06, SC-008 331 s, SC-009 0.365. The 10-million-point check peaks at 7.10 GB with one restored batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose
added a commit
that referenced
this pull request
Nov 26, 2026
…fter #425 (C-021) #425 moves a point on a cutting fault with the frame direction instead of to NaN. The C-021 capture (master a942177 with #424) had those NaN points in cutting_faults: 1 restored point, 1 value and 2 gradient rows, and one model id that they changed. The 5 changed outputs come from master 315dff4 with #425; the spec branch gives the same bits for all 970 golden arrays. The manifest records the update. On this branch a frame without faults takes the shared grid lookup, which does not call evaluate_gradient, so the #425 test of the NaN rule turns the lookup off to reach the member calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
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
Since #413 a point with a NaN coordinate evaluates to NaN.
GeologicalFeature.evaluate_value(..., fillnan='nearest')then passes those points tocKDTree.query, which raisesValueError: 'x' must be finite, check for nan or inf values.After #421 the fault-side check of
evaluate_gradientuses this path, soevaluate_model_gradientfails on a model with cutting faults (found while merging master into the spec 003 branch, #391: thecutting_faultsgolden model fails on mastera942177b).Fix
Only points with finite coordinates get the nearest value. A point with a NaN coordinate has no nearest point, so it stays NaN (consistent with #413). A call with no known value also stays NaN instead of failing on an empty tree.
Tests
test_fillnan_nearest_keeps_nan_for_points_with_a_nan_coordinateandtest_fillnan_nearest_without_known_values_gives_nanfail before the fix and pass after it.pytest tests: 2911 passed, 31 skipped.cutting_faultsmodel gradient of the spec 003 golden models evaluates again (158 points, no NaN rows).🤖 Generated with Claude Code
https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx