Skip to content

refactor: consolidate rectangular meshes — kernel-CDF takes the plain names - #403

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/rectangular-mesh-consolidation
Jul 23, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/rectangular-mesh-consolidation

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

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 names RectangularAdaptDensity / 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 / RectangularAdaptImage are now the kernel-density-CDF meshes (formerly RectangularKernelAdapt*), gaining optional bandwidth / n_knots kwargs (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. The RectangularKernel*, RectangularSpline*, RectangularRotatedAdaptImage classes and their interpolators/geometry are removed. RectangularUniform, the InterpolatorRectangular name/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; RectangularAdaptImage gains its first dedicated coverage; the empty interpolator/test_rectangular.py stub replaced with the transform/areas/interpolator tests)
  • PyAutoGalaxy suite against this branch — 1006 passed, zero source changes
  • PyAutoLens suite against this branch — 448 passed, zero source changes
  • af.Model composition: prior counts unchanged (AdaptDensity 2, AdaptImage 4, Uniform 2); bandwidth/n_knots resolve to kernel defaults at instantiation
  • Grep sweep: zero references to RectangularKernel|RectangularSpline|RectangularRotated|InvertPolySpline|create_transforms_kernel|spline_deg|density_components|forward_interp in autoarray/ + test_autoarray/
  • Workspace follow-up (separate PRs): update autolens_workspace_test/scripts/jax_grad variants to the plain names and re-run the strict-FD certification; stash autolens_workspace_developer spline/rotated experiments in PyAutoGut
Full API Changes (for automation & release notes)

Removed

  • aa.mesh.RectangularKernelAdaptDensity / aa.mesh.RectangularKernelAdaptImage — their implementation now lives under aa.mesh.RectangularAdaptDensity / aa.mesh.RectangularAdaptImage
  • aa.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 into interpolator.rectangular), interpolator.rectangular_spline (incl. InvertPolySpline and its JAX pytree registration), interpolator.rectangular_rotated_spline, interpolator.density_components (unwired), mesh_geometry.rectangular_rotated (MeshGeometryRectangularRotated)
  • Linear empirical-CDF implementation: the old InterpolatorRectangular class body, forward_interp / forward_interp_np, the linear create_transforms and the linear transformed-grid / mappings / areas helpers
  • AbstractMeshGeometry.__init__ no longer accepts spline_deg

Changed Behaviour

  • RectangularAdaptDensity / RectangularAdaptImage adapt via the smooth kernel-density CDF (Enzi et al. RTU formulation) instead of the linear empirical CDF: mappings, weights, areas_transformed and edges_transformed all 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-constant
  • MeshGeometryRectangular.areas_transformed / .edges_transformed always use the kernel CDF; kernel_bandwidth / kernel_knots of None (e.g. built by the uniform interpolator) fall back to the kernel defaults

Changed Signature

  • RectangularAdaptDensity(shape, bandwidth=None, n_knots=None) and RectangularAdaptImage(shape, weight_power, weight_floor, bandwidth=None, n_knots=None) — None resolves to KERNEL_CDF_DEFAULT_BANDWIDTH (1.0) / KERNEL_CDF_DEFAULT_KNOTS (64); not free parameters (excluded from af.Model priors)
  • InterpolatorRectangular(..., bandwidth=, n_knots=) — the class is now the kernel implementation (subclasses AbstractInterpolator directly; isinstance plot dispatch unaffected)
  • interpolator.rectangular.create_transforms / adaptive_rectangular_transformed_grid_from / adaptive_rectangular_mappings_weights_via_interpolation_from — kernel-implemented, now take mesh_pixels (where applicable), bandwidth, n_knots
  • adaptive_rectangular_areas_from moved from mesh_geometry.rectangular to interpolator.rectangular (kernel-implemented)

Added

  • AbstractMesh subclasses expose interpolator_kwargs — extra kwargs interpolator_from forwards to interpolator_cls ({} for RectangularUniform)

Migration

  • Before: aa.mesh.RectangularKernelAdaptDensity(shape=(30, 30), bandwidth=0.5)
  • After: aa.mesh.RectangularAdaptDensity(shape=(30, 30), bandwidth=0.5)
  • Spline / rotated meshes: removed with no in-source replacement — recover from git history (this commit's parent) if the multi-node work resumes.

Generated by the PyAutoLabs agent workflow.

… 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
…rt removal and LF line endings

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XK2ZZagTywsBZC4CZL66eB
@Jammy2211
Jammy2211 merged commit e921eb9 into main Jul 23, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/rectangular-mesh-consolidation branch July 24, 2026 08:48
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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.

refactor: consolidate rectangular meshes — kernel takes plain names, retire linear/spline/rotated

1 participant