Skip to content

fix(fault): keep a step direction where a cutting fault leaves no frame gradient - #425

Merged
lachlangrose merged 1 commit into
masterfrom
fix/cut-fault-frame-nan-direction
Nov 26, 2026
Merged

lachlangrose merged 1 commit into
masterfrom
fix/cut-fault-frame-nan-direction

Conversation

@lachlangrose

Copy link
Copy Markdown
Member

Problem

Since #421, a gradient whose tetrahedron still crosses a fault after the refinement is NaN ("a point on a fault has no single gradient"). A fault whose frame is cut by younger faults takes the step direction of apply_to_points from that gradient, so a point on a cutting fault is moved to NaN coordinates.

A builder that restores a regular grid through such a fault then fails in check_interpolation_geometry with ValueError: Cannot resize the grid (the grid bounds become NaN). Found while building a benchmark model with a chain of cutting faults (D cut by C, C by B, B by A): 215 of the 10 890 grid points of D were NaN, and the next group could not be built. It happens on master 315dff43 and on the spec 003 branch (#391).

Fix

In FaultSegment.apply_to_points, where the frame of a cut fault has a NaN gradient at a finite point, use the gradient of the frame without the cutting faults (interpolator.evaluate_gradient) at that point. A step only needs a direction.

Unchanged:

  • A frame without cutting faults keeps a NaN gradient, so its points stay NaN (the rule that test_fault_frame_validation::test_zero_gradient_protection_remains_effective[nan] checks).
  • A point with a NaN coordinate is not moved.

Tests

  • New tests/unit/modelling/test_cut_fault_step_direction.py (under 1 s): a real cut pair (OLD cut by YOUNG) with NaN frame gradients on every other point. The cut frame still moves every point, about as far as before (2 tests fail before the fix, pass after); a frame without cutting faults keeps the NaN (passes before and after).
  • The chain reproduction: D goes from 215 NaN grid points to 0.
  • Full pytest tests: 2914 passed, 31 skipped.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx

…me gradient

Since #421 a gradient whose tetrahedron still crosses a fault after the
refinement is NaN. A fault whose frame is cut by younger faults takes the
step direction of apply_to_points from that gradient, so a point on a
cutting fault was moved to NaN. A builder that restores a regular grid
through such a fault then failed with "Cannot resize the grid" (seen with
a chain of cuts: D cut by C, C by B, B by A; 215 of 10890 grid points of D
were NaN).

Where the frame of a cut fault has a NaN gradient at a finite point, use
the gradient of the frame without the cutting faults there; a step only
needs a direction. A frame without cutting faults keeps a NaN gradient,
so its points stay NaN as before (test_fault_frame_validation). A point
with a NaN coordinate is not moved.

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
#425 (open against master) keeps a step direction where a cutting fault
leaves no frame gradient after #421, so a point on a cutting fault is no
longer moved to NaN. The conflict is in apply_to_points: the branch takes
the frame gradient from _evaluate_frame; the fallback of #425 follows it.
A cut frame always takes the legacy member path, where the NaN comes from.

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
lachlangrose added a commit that referenced this pull request Nov 26, 2026
…fter #427 (C-021)

#427 restores a cutting fault before the fault it cuts. In cutting_faults
the frame of fault_1 is faulted by fault_0, so fault_0 is now restored
first and the frame of fault_1 makes no nested restoration. The 5
changed outputs of cutting_faults (group_0 value and gradient, the
surface at 50 and the unit boundary distances; the model ids do not
change) come from master 315dff4 with #425 and #427; the spec branch
gives the same bits for all 970 golden arrays.

The counts of cutting_faults follow: evaluate_model 2 fault calls (22),
group_0 gradient 9 (29), none nested; the value call keeps one batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
@lachlangrose
lachlangrose merged commit 67dbcc8 into master Nov 26, 2026
37 checks passed
@lachlangrose
lachlangrose deleted the fix/cut-fault-frame-nan-direction branch November 26, 2026 22:22
lachlangrose added a commit that referenced this pull request Nov 26, 2026
…o feat/003-fault-evaluation-performance

The branch already had the same fixes as merges of their PR branches.
Two conflicts: _fault_segment.py keeps the branch's placement of the #425
fallback (after the frame gradient of _evaluate_frame), and
test_cut_fault_step_direction.py keeps the branch's version that turns
the shared frame lookup off for the NaN-rule test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
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.

1 participant