Skip to content

fix(loop-interpolation): equality, gradient and weight data reach the solve - #416

Open
lachlangrose wants to merge 3 commits into
masterfrom
fix/interp-constraints-reach-solve
Open

lachlangrose wants to merge 3 commits into
masterfrom
fix/interp-constraints-reach-solve

Conversation

@lachlangrose

Copy link
Copy Markdown
Member

Fixes data that the interpolators accepted and then silently ignored, or crashed on. Found in a repo audit.

Equality constraints never reached the solve. add_equality_constraints stored them, but add_equality_block had no caller. Fault splays rely on these constraints. Example: fixing node 0 to 100 and solving gave 2.0.

  • They are now least-squares rows with EQUALITY_WEIGHT = 100. Rows are normalised to unit length and data weights default to 1, so this is a strong soft constraint that cg still solves.
  • On the native path they go to the core as node values.
  • add_equality_block, eq_const_* and equal_constraints are deleted.
  • add_splay without a region crashed with a pandas KeyError (data["X","Y","Z","val"]), and returned None when it could not find the overlap side. Both are fixed, so the default splay path now builds.

P1 ignored gradient constraints, and P2 crashed on them. P1's add_gradient_constraints was pass. P2's einsum expected the wrong array layout, and its unit test passed only because its fake support used the same wrong layout. P1 and P2 now share one strike/dip implementation, as FDI does. Data that an engine cannot use (P1 interface; P2 interface, inequality and inequality pairs) now gives a warning instead of being dropped silently.

Per-point weights were applied differently by each engine. FDI ignored the gradient weight column. P1 and P2 ignored the value and normal weight columns. P1 used an upper bound of 1.0 for inequality pairs, where FDI uses eps. The weight column is now used everywhere, and P1 passes eps. With the default weights of 1, FDI and native results do not change.

Behaviour changes (release note):

  • Fault splays now take effect.
  • PLI (P1) models with gradient data, or with non-default weight columns, give different fields: that data was ignored before.
  • P1 inequality pairs are tighter.
  • The npw /3 difference between FDI/native and P1/P2 is not changed.

Tests:

  • New tests: test_equality_constraints, test_gradient_and_weight_columns, and test_add_splay_with_the_default_region_builds. 11 of the 12 new package tests and the splay test fail on master.
  • Targeted runs: 240 passed and 16 skipped in the package tests (the native core is not installed). test_p2interpolator and test_reference_constraint_frames: 471 passed. test__fault_builder: 7 passed.
  • Run the package tests and the root tests separately: their conftests clash in one run.

Reviewed by a second agent: no bugs found in the diff. The splay KeyError it found is fixed in 749abfa.

🤖 Generated with Claude Code

lachlangrose and others added 3 commits November 25, 2026 21:05
… solve

- add_equality_constraints now adds least-squares rows with the weight
  EQUALITY_WEIGHT (100). Before, the rows went to equal_constraints and no
  solve used them. After a native setup, the rows go to the native core as
  values at the nodes. Remove the unused add_equality_block, the eq_const_*
  fields and equal_constraints.
- P1 and P2 add gradient (direction) constraints as FDI does: two rows
  with the strike and dip vectors. P1 used to drop them and P2 crashed on
  the real (n, 3, k) shape derivative layout. P1 and P2 now write a
  warning for data that they do not use (P1: interface; P2: interface,
  inequality, inequality pairs).
- Use the weight column of the data in all engines: FDI and native
  gradient and tangent, P1 and P2 value and normal. P1 gives eps as the
  upper bound of inequality pairs, as FDI does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
add_splay without a region read the fault data with
data["X", "Y", "Z", "val"], which pandas reads as one tuple key,
so the build stopped with KeyError. Select the four columns with a
list. When the overlap side cannot be found, return an empty mask
instead of None. clear_constraints now also clears the native
orthogonal and equality data, as reset does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test pinned that PLI assembled no gradient rows, so 8 gradient
points were unattributed. PLI now uses gradient data, so none are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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