Repository navigation
fix: Sibson weights from the cavity boundary, regular at internal edges - #685
Merged
Merged
Conversation
…ges (#610) The Watson per-triangle decomposition formed a circle through the query and every edge of every cavity triangle, including cavity-interior edges whose terms cancel. On an internal edge that circle is collinear: the code fell back to the seed triangle's barycentric row (correct only on hull edges; square centre got 0.5/0.5 on the diagonal instead of 0.25 x 4), and near one the huge cancelling terms were normalised before negatives were clipped (sum 1.12). Natural-neighbour areas are now summed from per-edge segment terms of the stolen regions (stored circumcentres on cavity-interior edges; the circle through q only on cavity-BOUNDARY edges; q|v bisector split at (q+v)/2), with a clockwise triangle negating its terms. Internal edges are never singular. Linear hull-edge rule only on exact hull collinearity. Round-off-sized areas snapped to 0 before normalising; clearly negative ones mark the row degenerate. Selected entries compacted to the front of each row. Same algorithm in the NumPy/JAX body and the numba body (parallel + serial). Numba serial kernel ~20% faster than before at HST size (61,600 queries). DelaunayNN magnification areas now integrate the Sibson basis (the kNN quadrature, shared): the dual-area approximation biased the identity-lens magnification by -2.65% once internal-edge weights were corrected; +0.04% now. Validation: independent Voronoi-clipping oracle (<=1e-10), square centre both diagonals and windings, hexagon 1/6, both-sided finite/nextafter edge probes (Lipschitz), affine/partition/support, hull limit, NumPy/numba/JAX-jit parity. Audit strict xfails (3) promoted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016nhQ8MFwfRFgwBVbYjP9Xd
This was referenced Nov 9, 2026
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.
Closes #610. This implements the approved plan (plan comment). Tier judge; merge by human
/prm. PR 1 of 2 (split by repo); the workspace PR is documentation-only, see below.Summary
Bug. The Watson per-triangle decomposition formed a circle through the query
qand every edge of every cavity triangle, including cavity-interior edges whose terms cancel in exact arithmetic. On an internal edge that circle is collinear:Fix: natural-neighbour areas from the cavity boundary. Each neighbour's stolen area
|cell_new(q) ∩ cell_old(v)|is a sum of per-edge segment terms½·cross(P−q, P′−q):(q+v)/2, which keeps every term local to one edge: static-shape for JAX, a flat loop for numba.So internal edges are never singular.
Rules by case:
≤ 1e-12·total) are snapped to 0 before normalising, so all bodies select the same support. A negative area beyond−1e-10·totalmarks the rowdegenerate(the perf: skip Sibson row padding in adaptive signals and unique mappings (DelaunayNN imaging) #629 contract is kept).-1holes.The same algorithm is in
_sibson_single_from_tables(NumPy/JAX) and_sibson_numba._sibson_from_tables(parallel + serial builds).judge)DelaunayNN likelihoods change wherever data points sit on or near internal edges. That's common: traced image-mesh vertices are data-pixel centres, and regular meshes are exactly cocircular. No currently pinned autolens_workspace_test likelihood uses DelaunayNN (51/51 scripts pass, below).
Also in this PR: DelaunayNN magnification areas
imaging/mesh_magnification.py's DelaunayNN identity leg went from −0.41% to −2.65% (1% tolerance), because its areas were the Delaunay dual areas, an approximation the old interpolant happened to flatter. I proved the interpolant itself correct on exact lattices (≤ 5e-12 vs the oracle). DelaunayNN now integrates its own Sibson basis functions, the kNN quadrature from #665, now shared viabasis_quadrature_points_from/basis_integral_areas_from: identity +0.04%, lensed −0.23%, better than main's −0.41% / −0.27%. This affects onlyareas_for_magnification(the magnification diagnostic and plotting), not the likelihood. kNN behaviour is unchanged.Performance (numba, HST size: 61,600 queries, 1,530 vertices, 4 cores, interleaved with main)
prange), mediansA first port was 1.5–2.8× slower. Three exact rewrites removed that:
The dead
_pairwise_sum/_block_sumhelpers are removed. The open Mind draftsibson_serial_kernel_loses_allocation_hoistingshould be re-measured on this body.API Changes
Internal algorithm change. Sibson weights at and near internal edges change (correct now); DelaunayNN likelihoods and magnification areas change.
See full details below.
Test Plan
test_sibson_internal_edges.py(43 tests, numpy / numba / jax-jit) against an independent Voronoi half-plane-clipping oracle (test-local, no production code):nextafteron a lattice and a random mesh:|w(±δ) − w(0)| ≤ 200·δ + 1e-12.test_sibson_square_center_matches_independent_symmetry_oracle,test_sibson_near_edge_preserves_partition_after_positive_filter, andtest_exact_nextafter_boundary_continuity_and_locator_fault[sibson].test_sibson_numba.py::test__thin_triangle__…: it pinned the old symptom (NaN rows 1e-15 off an internal edge). It's rewritten to pin the correct behaviour: finite partition, continuous across the edge, off-edge neighbours kept; values checked against the oracle (≤ 1.3e-12).jax_likelihoodscript,misc/jax_assertions/{delaunay_nn, delaunay_nn_caps}.pyandimaging/jax_grad/delaunay.py: 51/51 pass. That includesimaging/mesh_magnification.pyandmesh_interpolator_source_recovery.py.Full API Changes (for automation & release notes)
Added
autoarray.inversion.mesh.interpolator.sibson.sibson_mappings_weights_from(points_np, query_points_np, …): NumPy Sibson rows for arbitrary query points.autoarray.inversion.mesh.interpolator.sibson.SIBSON_ZERO_AREA_TOLERANCE,SIBSON_NEGATIVE_AREA_TOLERANCE.autoarray.inversion.mesh.mesh_geometry.delaunay.MeshGeometryDelaunayNN,basis_quadrature_points_from,basis_integral_areas_from.Removed
_sibson_numba._pairwise_sum,_block_sum(private, now unused).Changed Behaviour
InterpolatorDelaunayNN,mesh.DelaunayNN) on and near internal Delaunay edges: correct natural-neighbour weights, continuous across edges. Hull edges use the linear rule only on exact collinearity.InterpolatorDelaunayNN.mesh_geometry.areas_for_magnification: Sibson basis integrals instead of the Delaunay dual areas.Migration
Generated by the PyAutoLabs agent workflow.
Generated by Claude Code