Repository navigation
fix: exact mesh magnification areas (RectangularUniform + adaptive rectangular) with per-mesh tests (arc phase 4a) - #664
Merged
Conversation
…ells The uniform mesh's geometry routed edges_transformed / areas through the adaptive meshes' kernel-CDF guard-ring convention, which does not describe the uniform mapper (bilinear between overlay pixel centres, no CDF, no guard ring). Magnifications from it were biased by -77% to +259% (PyAutoArray#659). The uniform interpolator now builds its geometry with transform="uniform", whose edges are the uniform cells centred on every overlay node (the same cells its imshow plot draws). xp-aware; jit/grad checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016nhQ8NkVvJhhqNSibeGcBQ
…drature) For all nine meshes: areas sum to the analytic covered domain, the identity-lens magnification of a reconstructed Gaussian against the mapper's exact quadrature, and pinned guard-cell / hull-vertex / zeroed-ring semantics. Approximate meshes carry measured, documented tolerances (PyAutoArray#659). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016nhQ8NkVvJhhqNSibeGcBQ
…ximation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016nhQ8NkVvJhhqNSibeGcBQ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016nhQ8NkVvJhhqNSibeGcBQ
…ular meshes The adaptive rectangular meshes' areas_for_magnification pushed each node's node-midpoint cell through the inverse CDF. That is not the integral of the node's bilinear basis function once the CDF bends across a cell (the rank CDF's staircase on tied coordinates, a steep adapt-image CDF), and biased magnifications by up to +14% lensed / +11% unlensed. New adaptive_rectangular_hat_areas_from integrates each node's separable basis hat_r(g_y(y)) * hat_c(g_x(x)) exactly per axis, through the same forward transform the mapper uses, over the over-sampled data's bounding box. JAX-jit/grad safe; numpy and JAX agree to 1e-14. areas_transformed and edges_transformed (plotting) are unchanged. Lensed workspace check vs simulator truth: BilinearAdaptImage +14.43% -> -0.57%, RTUAdaptImage +8.56% -> +0.08%; identity BilinearAdaptDensity +11.23% -> -0.34%. Tolerances tightened to match. Refs #659 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #659 — Source & Cluster arc phase 4a.
What changed
areas_for_magnification: uses its own uniform cells centred on the overlay nodes. Before, it reused the adaptive meshes' kernel-CDF guard-ring geometry, which doesn't describe this mapper, so magnifications were off by −77% to +259%.areas_for_magnificationis now the exact integral of each node's bilinear basis function, computed per axis through the mapper's own forward CDF (adaptive_rectangular_hat_areas_from). The old node-midpoint cells were wrong wherever the CDF bends across a cell. They also gave a live row zero area on coarse meshes.areas_transformed/edges_transformed(used for plotting) are unchanged.test_areas_for_magnification.pytests every mesh (all 9) for area sum, identity-lens magnification against the mapper's own integral and the analytic integral, and guard-cell behaviour.Measured (autolens_workspace_test
imaging/mesh_magnification.py, vs simulator truth)KNN and KNNBarycentric still use Delaunay dual areas, which only approximate their interpolants. Their tolerances record the measured error, and the proper fix is phase 4b. RTUAdaptDensity's −1.82% lensed is unchanged by the new areas, so it comes from the reconstruction, not the areas.
Checks
jax.jitandjax.gradwork and give finite gradients.imaging/mesh_magnification.py,misc/latent/latent_integration_smoke{,_jax}.py,imaging/mesh_interpolator_source_recovery.py,misc/jax_assertions/rectangular_geometry.py. The full smoke run was cut short on 10-28 when the laptop ran low on memory, so PR CI is the first full smoke run.Known limit
On a strongly distorted toy (radial map with a=0.3), BilinearAdaptImage's areas are +6–13% against the mapper's own integral. The areas cover the bounding box, and the separable interpolant extends into box corners that no traced data reaches. The realistic lensed check above is unaffected. This is recorded on the 4b prompt.
Companion: autolens_workspace_test PR (integration check) — merge this one first.
🤖 Generated with Claude Code