refactor: consolidate rectangular meshes — kernel-CDF takes the plain names#403
Merged
Merged
Conversation
… names RectangularAdaptDensity/AdaptImage are now the kernel-density-CDF meshes (formerly RectangularKernelAdapt*, #374); RectangularUniform is unchanged. Removed: the linear empirical-CDF implementation, the spline-CDF pair (#289), the PCA-rotated multi-node mesh (#323), density_components, and their interpolators/geometry/tests. InterpolatorRectangular keeps its name/module path as the kernel implementation; prior-config keys and downstream imports are unchanged. Closes #402. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XK2ZZagTywsBZC4CZL66eB
This was referenced Jul 23, 2026
Merged
…rt removal and LF line endings Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XK2ZZagTywsBZC4CZL66eB
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.
Summary
Consolidates the rectangular mesh family down to the two meshes that matter: the kernel-density-CDF adaptive meshes (the certified gradient path, #374) and
RectangularUniform(no interpolation; the HowToLens methodology illustration). The kernel implementation takes over the plain namesRectangularAdaptDensity/RectangularAdaptImage, and three superseded generations leave the source: the linear empirical-CDF path (piecewise-constant likelihood in mass/shear at over-sampling 1 and on the interferometer sparse path), the spline-CDF pair (#289, shipped with a known JIT-oscillation limitation, never FD-certified), and the PCA-rotated multi-node experiment (#323, built on the spline chain — recoverable from git history if that work resumes).Closes #402.
API Changes
The adaptive rectangular meshes keep their names but change implementation:
RectangularAdaptDensity/RectangularAdaptImageare now the kernel-density-CDF meshes (formerlyRectangularKernelAdapt*), gaining optionalbandwidth/n_knotskwargs (defaults unchanged from the kernel classes; not free parameters — prior counts are unchanged). Results shift numerically (linear → kernel CDF; certified FoM parity 2.7e-5–6.3e-4 relative), and mass/shear gradients are now smooth in every configuration. TheRectangularKernel*,RectangularSpline*,RectangularRotatedAdaptImageclasses and their interpolators/geometry are removed.RectangularUniform, theInterpolatorRectangularname/module path,MeshGeometryRectangular,rectangular_edge_pixel_list_from, and all prior-config keys are unchanged — PyAutoGalaxy/PyAutoLens need zero source changes.See full details below.
Test Plan
pytest test_autoarray/— 892 passed (kernel tests re-homed under the plain names; spline/rotated tests removed;RectangularAdaptImagegains its first dedicated coverage; the emptyinterpolator/test_rectangular.pystub replaced with the transform/areas/interpolator tests)af.Modelcomposition: prior counts unchanged (AdaptDensity 2, AdaptImage 4, Uniform 2);bandwidth/n_knotsresolve to kernel defaults at instantiationRectangularKernel|RectangularSpline|RectangularRotated|InvertPolySpline|create_transforms_kernel|spline_deg|density_components|forward_interpinautoarray/+test_autoarray/autolens_workspace_test/scripts/jax_gradvariants to the plain names and re-run the strict-FD certification; stashautolens_workspace_developerspline/rotated experiments in PyAutoGutFull API Changes (for automation & release notes)
Removed
aa.mesh.RectangularKernelAdaptDensity/aa.mesh.RectangularKernelAdaptImage— their implementation now lives underaa.mesh.RectangularAdaptDensity/aa.mesh.RectangularAdaptImageaa.mesh.RectangularSplineAdaptDensity/aa.mesh.RectangularSplineAdaptImage— superseded spline-CDF meshes (Add RectangularSplineAdapt{Density,Image} meshes for gradient-based samplers #289)aa.mesh.RectangularRotatedAdaptImage— PCA-rotated multi-node experiment (feat: RectangularRotatedAdaptImage — PCA rotation fixes multi-source ghost-peak failure #323)autoarray.inversion.mesh.interpolator.rectangular_kernel(merged intointerpolator.rectangular),interpolator.rectangular_spline(incl.InvertPolySplineand its JAX pytree registration),interpolator.rectangular_rotated_spline,interpolator.density_components(unwired),mesh_geometry.rectangular_rotated(MeshGeometryRectangularRotated)InterpolatorRectangularclass body,forward_interp/forward_interp_np, the linearcreate_transformsand the linear transformed-grid / mappings / areas helpersAbstractMeshGeometry.__init__no longer acceptsspline_degChanged Behaviour
RectangularAdaptDensity/RectangularAdaptImageadapt via the smooth kernel-density CDF (Enzi et al. RTU formulation) instead of the linear empirical CDF: mappings, weights,areas_transformedandedges_transformedall shift numerically (FoM parity 2.7e-5–6.3e-4 relative, certified in feat: kernel-density CDF meshes RectangularKernelAdaptDensity/Image #374); mass/shear gradients are smooth in every configuration, including pixelization over-sampling 1 and the interferometer sparse path where the linear CDF was exactly piecewise-constantMeshGeometryRectangular.areas_transformed/.edges_transformedalways use the kernel CDF;kernel_bandwidth/kernel_knotsofNone(e.g. built by the uniform interpolator) fall back to the kernel defaultsChanged Signature
RectangularAdaptDensity(shape, bandwidth=None, n_knots=None)andRectangularAdaptImage(shape, weight_power, weight_floor, bandwidth=None, n_knots=None)—Noneresolves toKERNEL_CDF_DEFAULT_BANDWIDTH(1.0) /KERNEL_CDF_DEFAULT_KNOTS(64); not free parameters (excluded fromaf.Modelpriors)InterpolatorRectangular(..., bandwidth=, n_knots=)— the class is now the kernel implementation (subclassesAbstractInterpolatordirectly;isinstanceplot dispatch unaffected)interpolator.rectangular.create_transforms/adaptive_rectangular_transformed_grid_from/adaptive_rectangular_mappings_weights_via_interpolation_from— kernel-implemented, now takemesh_pixels(where applicable),bandwidth,n_knotsadaptive_rectangular_areas_frommoved frommesh_geometry.rectangulartointerpolator.rectangular(kernel-implemented)Added
AbstractMeshsubclasses exposeinterpolator_kwargs— extra kwargsinterpolator_fromforwards tointerpolator_cls({}forRectangularUniform)Migration
aa.mesh.RectangularKernelAdaptDensity(shape=(30, 30), bandwidth=0.5)aa.mesh.RectangularAdaptDensity(shape=(30, 30), bandwidth=0.5)Generated by the PyAutoLabs agent workflow.