Repository navigation
fix(fault): restore a cutting fault before the fault it cuts - #427
Conversation
A fault created with faults=[A] is faulted by the younger fault A, so A must be restored first. Features keep their faults newest first, and A must exist before the fault it cuts, so A came after it in every list: restore_through applied the cut fault first, its frame restored every point through A again inside each step, and the result near the intersection differed. In a chain of cutting faults the work multiplied at each level (a 5-fault test model: 3460 fault calls and 14.2 s for 2000 points; restored cutters first: 5 calls and 0.034 s). restore_through now orders the faults so that a cutting fault comes before every fault of the list that it cuts (cutters_first); faults with no such relation keep the order of the list, so models without faulted faults do not change. Moving points forward (reverse) puts the cutting fault last. The builder rotates data vectors in the same order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
_cutters read the members by index, which calls __getitem__ of any fault-like object in a list (a test double asserts its key). The members are in StructuralFrame.features. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
#427 (open against master) restores a cutting fault before the fault it cuts, so a fault frame displaced by a younger fault no longer restores every point through it again at each step. It is the same commit as on the PR branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
…feat/003-fault-evaluation-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
…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
A fault applied through a list that names only its direct cutters (a fault frame builder, or a feature with faults=[C]) restored through C alone. The frame of C was built in the space restored through its own cutter B, so C restored every point through B again at each step, and B through A: the nesting gained one level for each link of a chain, and the cost multiplied (build of a 5-fault chain: 272.7 s and 44850 fault calls). restore_through now adds, transitively, the faults that cut a fault of the list (with_cutters) and restores them in one pass, youngest first, each told what is already restored. A fault frame cut by B is then also moved by the younger faults that cut B, where their displacement reaches it. The same 5-fault chain builds in 7.0 s (1923 fault calls); a 6-fault chain in 15 s. The builder rotates data vectors through the same faults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
|
Follow-up in commit 79f66bf: restore the whole chain of cutting faults in one pass ( Ordering within a list was not enough: a fault frame builder, or a feature with
Build time of a cutting chain (one fault cut by the previous one):
New test |
…to feat/003-fault-evaluation-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
…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
Problem
A fault created with
faults=[A]is faulted by the younger faultA, soAmust be restored first. But features keep their faults newest first (FeatureRelationshipManager.add_faultswalksreversed(features)), andAmust exist before the fault it cuts, soAalways comes after the fault it cuts in every list.restore_throughthen applies the cut fault first:Aagain inside each of its steps (nestedapply_to_points), and the work multiplies at every level of a chain of cutting faults;Afirst.Measured on a 5-fault test model with a chain of cuts (2000 points): 3460 fault calls, 14.2 s in the current order; 5 calls, 0.034 s with the cutting faults first. About 2 % of the points differ, by up to 72 m (max displacement 112 m), all near intersections. Deeper chains grow roughly 20× per level.
Fix
restore_throughorders the faults withcutters_first: a cutting fault (from the fault frame builders, or the frame members once built) comes before every fault of the list that it cuts. Faults without such a relation keep the order of the list, so models without faulted faults do not change. Moving points forward (reverse=True) puts the cutting fault last and otherwise keeps the list order. The feature builder rotates data vectors in the same order. A cycle of relations keeps the list order.The global convention for unrelated faults (newest first) is unchanged here; that is a separate decision.
Tests
tests/unit/modelling/test_cut_fault_restore_order.py: the ordering helper (cutter first, unrelated order kept, forward order unchanged without relations), and a model withOLDcut byYOUNG: a feature restoresyoungthenold, with 2 fault calls and the same points as restoring by hand. On master that model makes 14 fault calls, restoresoldfirst and differs by up to the full slip (0.12 in a unit box).pytest tests: 2914 passed, 31 skipped. Ruff: no new findings.🤖 Generated with Claude Code
https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx