Skip to content

feat: interpolated view of Delaunay/kNN source reconstructions - #701

Merged
Jammy2211 merged 4 commits into
mainfrom
feature/delaunay-interpolated-plot
Nov 18, 2026
Merged

Jammy2211 merged 4 commits into
mainfrom
feature/delaunay-interpolated-plot

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes #700. Delaunay/kNN source reconstructions are drawn as flat-shaded triangles. These show where the mesh spends resolution, but they are not the interpolant the likelihood uses between vertices, as reported on PyAutoLabs/.github#46.

  • Default plot unchanged: plot_mapper and plot_inversion_reconstruction still draw flat triangles by default. The _plot_delaunay docstring now says plainly what they show and what they do not.
  • New interpolated view: builds a fresh interpolator of the mapper's own type, with the same mesh and mesh_grid, and evaluates it on a uniform plot grid over the panel extent (400×400 by default, configurable). The result is drawn with imshow.
    • The figure equals the plot-grid mapping_matrix @ reconstruction: barycentric weights for Delaunay, the mesh's own weights for kNN, KNNBarycentric and DelaunayNN.
    • Pixels outside the mesh hull are transparent.
    • Log scales clip to the norm floor.
    • Rectangular meshes ignore the flag.
    • The weights are applied directly; no dense mapping matrix is formed.
  • inversion_#.png (irregular meshes): the right-hand column holds the source plane, matching the lens fit.png: "Source Plane (Max Zoom)" (panel 3), "Source Plane (Interpolated)" (panel 7, max-zoom extent) and "Source Plane (No Zoom)" (panel 11, always bottom right). Mesh Pixel Grid Overlaid, Noise-Map and Regularization move to panels 4–6. The interpolated panel is square, with a colorbar the full height of the panel. Rectangular inversions are pixel-identical to main.
  • Config:
    • visualize/general.yaml gets inversion: interpolated_pixels: 400.
    • plots.yaml gets fit: subplot_fit_source_interpolated: true. PyAutoLens reads it (feat: fit.png switch for the interpolated source panel PyAutoLens#864): by default the interpolated panel is in the middle of the right-hand column of fit.png, between Max Zoom and No Zoom, and false puts Mid Zoom there instead.

API Changes

Added only; nothing removed or changed.

  • plot_inversion_reconstruction / plot_mapper gain interpolated=False and interpolated_shape_native=None.
  • New helpers in autoarray.plot.inversion: interpolated_reconstruction_from and mapper_has_interpolated_view.
  • subplot_of_mapper uses a new layout for irregular meshes: Max Zoom / Interpolated / No Zoom in the right-hand column.

See full details below.

Test Plan

  • test_autoarray/plot/test_inversion_interpolated.py, 11 new tests:
    • the interpolated image equals a fresh interpolator's mapping_matrix @ reconstruction on the plot grid, for Delaunay, KNearestNeighbor, KNNBarycentric and DelaunayNN;
    • a linear source is reproduced exactly (Delaunay, DelaunayNN), and row 0 is at the top;
    • under a log scale no value falls below the norm floor;
    • interpolated=True draws a raster and the default draws triangles;
    • rectangular meshes skip;
    • panel 11 is present for Delaunay and absent for rectangular.
  • Full suite: python -m pytest test_autoarray: 2399 passed, 70 skipped. After the layout changes (e8a174a6): 2470 passed (laptop).
  • Reporter's minimal example (true Sersic at the vertices of a 500-pixel Hilbert-Delaunay mesh):
    • the interpolated panel matches the likelihood's mapping_matrix @ recon to 1.8e-15;
    • the median deviation from the true Sersic is 1.4e-4 of the peak.
  • Laptop follow-ups (2026-11-18), details on feat: Delaunay source plots — add the likelihood's interpolated view #700 (feat: Delaunay source plots — add the likelihood's interpolated view #700 (comment)):
    • smoke 124/124 across autolens_workspace, autolens_workspace_test and HowToLens;
    • Delaunay/KNN figures re-rendered in autolens_visualization and autogalaxy_visualization and pixel-diffed against main: only the intended figures changed, and the rectangular control is identical;
    • figures approved by the human.

Heart: the published board was GREEN (2026-11-17T15:25Z), with no blockers on the touched repos.

Full API Changes (for automation & release notes)

Added

  • autoarray.plot.inversion.interpolated_reconstruction_from(mapper, pixel_values, extent, shape_native=None) -> np.ndarray: the mapper's interpolant on a uniform grid; NaN outside the mesh hull.
  • autoarray.plot.inversion.mapper_has_interpolated_view(mapper) -> bool: True for Delaunay, kNN and natural-neighbour mappers.
  • plot_inversion_reconstruction(..., interpolated=False, interpolated_shape_native=None).
  • autoarray.inversion.plot.mapper_plots.plot_mapper(..., interpolated=False, interpolated_shape_native=None).
  • Config keys:
    • visualize/general.yaml inversion.interpolated_pixels: 400;
    • visualize/plots.yaml fit.subplot_fit_source_interpolated: true.

Changed Behaviour

  • subplot_of_mapper (inversion_#.png) with irregular meshes: right-hand column = Source Plane (Max Zoom) / Source Plane (Interpolated) / Source Plane (No Zoom); Mesh Pixel Grid Overlaid, Noise-Map and Regularization move to panels 4–6. Rectangular meshes are unchanged.

Migration

  • None.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_016nhQ8MtKvVD9fBkNBqcMb4

Delaunay/kNN reconstructions are drawn as flat-shaded triangles, which show
where the mesh spends resolution but are not the interpolant the likelihood
uses between vertices (Discussion PyAutoLabs/.github#46).

- plot_inversion_reconstruction / plot_mapper gain `interpolated=True`: a
  fresh interpolator of the mapper's own type (same mesh and mesh_grid) is
  evaluated on a uniform plot grid over the panel extent and drawn with
  imshow, so the figure equals mapping_matrix @ reconstruction. Barycentric
  for Delaunay, kNN / Sibson weights for those meshes; outside the mesh hull
  is transparent; log scales clip to the norm floor; rectangular meshes
  ignore the flag.
- interpolated_reconstruction_from / mapper_has_interpolated_view helpers.
- inversion_#.png panel 11: "Source Reconstruction (Interpolated)" for
  irregular meshes.
- Flat triangles stay the default; the _plot_delaunay docstring now says
  plainly what they show and what they do not.
- config: visualize/general.yaml inversion.interpolated_pixels (400) and
  plots.yaml fit.subplot_fit_source_interpolated (false), read by the
  PyAutoLens fit plotters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016nhQ8MtKvVD9fBkNBqcMb4
claude and others added 3 commits November 17, 2026 22:01
…restores mid zoom

fit.subplot_fit_source_interpolated now defaults to true. With an
irregular-mesh source, fit.png right-hand column is max zoom, no zoom (flat
triangles) and the likelihood interpolant bottom right; false (or a
rectangular / parametric source) restores max, mid and no zoom. Human
decision on PyAutoArray#700, 2026-11-17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016nhQ8MtKvVD9fBkNBqcMb4
The kNN interpolators import jax, so their mapping-matrix cases fail on the
no-jax CI leg (unittest-nojax). Skip them there, as the repository's other
jax-dependent tests do; Delaunay and DelaunayNN cases still run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016nhQ8MtKvVD9fBkNBqcMb4
Irregular-mesh inversion_#.png puts the source plane in the right-hand
column like the lens fit.png: Source Plane (Max Zoom), Source Plane
(Interpolated) over the max-zoom extent, Source Plane (No Zoom).
Rectangular meshes keep their layout unchanged. The interpolated panel
is now square with a full-height colorbar (imshow no longer resets the
box aspect).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 7917d7a into main Nov 18, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/delaunay-interpolated-plot branch November 18, 2026 10:10
@pyautolabs-bot pyautolabs-bot Bot removed the pending-release PR queued for the next release build label Nov 19, 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.

feat: Delaunay source plots — add the likelihood's interpolated view

2 participants