Conversation
Detailed 13-PR plan to remove MatPlot, MatWrap, Visuals, and Output from PyAutoArray/PyAutoGalaxy/PyAutoLens in favour of direct matplotlib calls with explicit parameters. Key design decisions documented: - ax-passing pattern replaces subplot state machine - overlay data as typed list/array args replaces Visuals objects - save_figure() helper replaces Output class - 3 linear ticks via np.linspace replaces XTicks/YTicks classes - only visualize/general.yaml survives for figsize config https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
… all autolens plotters - Update autolens Plotter base class to inherit from autogalaxy's Plotter (which has _plot_array/_plot_grid bridge methods) instead of autoarray's AbstractPlotter - Replace self.mat_plot_2d.plot_array() with self._plot_array() in: TracerPlotter, FitImagingPlotter, FitInterferometerPlotter, SubhaloPlotter, SubhaloSensitivityPlotter - SubhaloPlotter and SubhaloSensitivityPlotter now inherit from autolens Plotter instead of autoarray AbstractPlotter to gain the bridge helpers https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
Add autolens_workspace_test/ to .gitignore to prevent the external test workspace (a separate git repository) from being tracked as an untracked file in this repo. https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
Patches to apply in sibling repos to implement the same plot refactoring done in autolens. Apply with: git am < patches/autoarray/000*.patch https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
…rray() with direct lines=/positions= kwargs - abstract_plotters.py: Plotter._plot_array(array, auto_labels, lines=, positions=, visuals_2d=) uses autoarray.plot.plots.array.plot_array() directly; _to_lines()/_to_positions() helpers - tracer_util.py: add critical_curves_from(), caustics_from(), lines_of_planes_from() computing curves via LensCalc, returning plain numpy arrays; legacy visuals_2d_of_planes_list_from retained - tracer_plotters.py: cached _tangential/radial_critical_curves/caustics properties; figures_2d passes lines= directly; galaxies_plotter_from builds Visuals2D from cached curves - fit_imaging_plotters.py: lines_of_planes via tracer_util; _lines_for_plane() helper; figures_2d/_of_planes pass lines= not visuals_2d= - fit_interferometer_plotters.py: same pattern; dirty_model_image uses lines= - conftest.py: PlotPatch also patches matplotlib.figure.Figure.savefig - pyproject.toml: pin autogalaxy to claude/refactor-plotting-module-3ZdD8 https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
Convert to raw string to suppress DeprecationWarning for \D in LaTeX math. https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
…ray2DPlotter Array2DPlotter (from PyAutoArray) only reads visuals_2d.lines via _lines_from_visuals, not the galaxy-specific tangential/radial_critical_curves fields. Convert them to plain numpy arrays passed via Visuals2D(lines=...) using critical_curves_from() / caustics_from() from tracer_util. https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
- Remove Visuals1D/Visuals2D from all plotter __init__ signatures - Replace mat_plot_2d.plot_array/plot_grid/plot_yx calls with standalone functions - TracerPlotter: add cached critical-curve/caustic properties, pass curves directly to GalaxiesPlotter as tangential_critical_curves/radial_critical_curves - FitImagingPlotter, FitInterferometerPlotter: remove visuals_2d_of_planes_list - SubhaloPlotter: remove visuals_2d; use Array2DPlotter(array_overlay=) directly - SubhaloSensitivityPlotter: remove visuals_2d; use Array2DPlotter(array_overlay=) - analysis/plotter_interface: remove visuals_2d; use positions= directly - imaging/interferometer model visualizers: remove visuals_2d_of_planes_list calls - fit_point_plotters: fix plot_grid() call to not use removed positions= kwarg - PyAutoArray plot_array: guard colorbar creation against LogNorm vmin==vmax All 176 tests pass. https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
…cmap=/use_log10= API Replace mat_plot_2d=/mat_plot_1d= constructor arguments across all plotter classes with the simplified output=/cmap=/use_log10= API. Eliminates MultiFigurePlotter, MultiYX1DPlotter dependencies and all MatPlot wrapper objects throughout autolens. Key changes: - All Plotter subclasses (TracerPlotter, FitImagingPlotter, FitInterferometerPlotter, FitPointDatasetPlotter, PointDatasetPlotter, SubhaloPlotter, SubhaloSensitivityPlotter) now accept output=, cmap=, use_log10= directly - SubhaloPlotter: replaced update_mat_plot_array_overlay with direct array_overlay= arg to Array2DPlotter; subplot methods use plt.subplots + _save_subplot pattern - SubhaloSensitivityPlotter: same pattern, sensitivity_to_fits uses Output directly - plotter_interface.py files updated: output_from() call (no quick_update arg), subplot filename fixed to subplot_fit_combined - FitInterferometerPlotter: removed invalid subplot delegation to meta plotter - Fixed variable shadowing bug in figures_2d(ax=None) for point plotters: standalone flag captured before positions block to avoid ax rebinding affecting fluxes block - All test files updated from mat_plot_2d=aplt.MatPlot2D(output=...) to output=... https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
Removes re-exports of AbstractMatWrap subclasses that no longer exist in autoarray.plot.wrap (Units, Figure, Axis, Title, YLabel, XLabel, YTicks, XTicks, TickParams, ColorbarTickParams, Text, Annotate, Legend, YXPlot, FillBetween, and all two_d scatter/plot classes). Keeps only Cmap, Colorbar, and Output which remain in autoarray.plot.wrap.base. Also removes mat_wrap_2d section from test config visualize.yaml since those wrap class configurations are no longer relevant. https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
…nctions Replace all *Plotter classes in autolens/*/plot/ with standalone subplot_* functions. The new design eliminates class-based plotting in favour of simple functions that accept fit/tracer objects and write figures directly to disk. Key changes: - Create autolens/plot/plot_utils.py: shared plot_array, plot_grid, _save_subplot, _to_lines, _critical_curves_from, _caustics_from helpers - Create tracer_plots.py, fit_interferometer_plots.py, fit_point_plots.py, point_dataset_plots.py with subplot_* standalone functions - Delete tracer_plotters.py, fit_imaging_plotters.py, fit_interferometer_plotters.py, fit_point_plotters.py, point_dataset_plotters.py - Update all plotter_interface.py files to call standalone functions directly - Update autolens/plot/__init__.py to export only subplot_* functions - Keep abstract_plotters.py as a compatibility shim for subhalo.py/sensitivity.py - Fix subplot_fit_log10: avoid vmin=0.0 with use_log10=True (matplotlib crash) - Update test config visualize.yaml to include fit_imaging subplot settings - Rewrite all plotter tests to test standalone functions https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
…ubplot functions - Remove SubhaloPlotter from subhalo.py; replace with subplot_detection_imaging and subplot_detection_fits standalone functions in lens/plot/subhalo_plots.py - Remove SubhaloSensitivityPlotter from sensitivity.py; replace with subplot_tracer_images, subplot_sensitivity, subplot_figures_of_merit_grid standalone functions in lens/plot/sensitivity_plots.py - Delete autolens/plot/abstract_plotters.py (no longer needed) - Update autolens/plot/__init__.py: export only plot_array, plot_grid, wrap classes, and all subplot_* functions; remove all *Plotter class exports - Fix analysis/plotter_interface.py: replace aplt.Array2DPlotter usage in image_with_positions with standalone plot_array call - Add vmin/vmax params to plot_array in plot_utils.py for coordinated colormaps - Rename test files from test_*_plotters.py to test_*_plots.py - All 173 tests pass https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
There was a problem hiding this comment.
Pull request overview
This PR refactors PyAutoLens plotting away from class-based *Plotter objects toward standalone subplot_* functions and explicit overlay data (e.g. critical curves / caustics as line arrays), updating plotter interfaces and tests accordingly.
Changes:
- Replaced multiple plotter classes (e.g. tracer / point / interferometer plotters) with standalone
subplot_*plotting functions and centralized matplotlib save helpers. - Added new overlay/line utilities (e.g.
lines_of_planes_from,critical_curves_from,caustics_from) and updated plotter interfaces to call the new plotting API. - Updated tests/config to match new plotting entrypoints and savefig patching.
Reviewed changes
Copilot reviewed 40 out of 45 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| test_autolens/point/plot/test_point_dataset_plotters.py | Removed plotter-class based tests (replaced by standalone subplot tests). |
| test_autolens/point/plot/test_point_dataset_plots.py | New tests for subplot_dataset output. |
| test_autolens/point/plot/test_fit_point_plotters.py | Removed plotter-class based tests (replaced by standalone subplot tests). |
| test_autolens/point/plot/test_fit_point_plots.py | New tests for subplot_fit output. |
| test_autolens/point/model/test_plotter_interface_point.py | Updated to match new plotting entrypoints. |
| test_autolens/lens/plot/test_tracer_plotters.py | Removed plotter-class based tests (replaced by standalone subplot tests). |
| test_autolens/lens/plot/test_tracer_plots.py | New tests for tracer subplot helpers. |
| test_autolens/interferometer/plot/test_fit_interferometer_plotters.py | Removed plotter-class based tests (replaced by standalone subplot tests). |
| test_autolens/interferometer/plot/test_fit_interferometer_plots.py | New tests for interferometer subplot helpers. |
| test_autolens/interferometer/model/test_plotter_interface_interferometer.py | Updated expectations for outputs from new interface implementation. |
| test_autolens/imaging/plot/test_fit_imaging_plotters.py | Removed imaging plotter-class tests (now covered via interfaces). |
| test_autolens/imaging/model/test_plotter_interface_imaging.py | Updated to new interface behavior and outputs. |
| test_autolens/conftest.py | Patches both pyplot.savefig and Figure.savefig to capture outputs. |
| test_autolens/config/visualize.yaml | Updated plot settings and removed old mat_wrap_2d styling blocks. |
| test_autolens/analysis/test_plotter_interface.py | Updated analysis plotter interface tests for new plotting path. |
| pyproject.toml | Changed autogalaxy dependency to a GitHub VCS URL. |
| patches/autogalaxy/0001-PR-G1-G2-replace-mat_plot_2d.plot_array-with-_plot_a.patch | Added patch file for downstream autogalaxy plotting refactor. |
| patches/autoarray/0003-PR-A3-replace-mat_plot_2d.plot_array-in-FitImagingPl.patch | Added patch file for downstream autoarray plotting refactor. |
| autolens/point/plot/point_dataset_plotters.py | Deleted plotter class in favor of standalone plotting functions. |
| autolens/point/plot/point_dataset_plots.py | New standalone subplot function for PointDataset. |
| autolens/point/plot/fit_point_plotters.py | Deleted plotter class in favor of standalone plotting functions. |
| autolens/point/plot/fit_point_plots.py | New standalone subplot function for FitPointDataset. |
| autolens/point/model/plotter_interface.py | Updated interface to call new standalone point plotting functions. |
| autolens/plot/plot_utils.py | New shared plotting/save helpers and overlay extraction helpers. |
| autolens/plot/abstract_plotters.py | Removed Plotter wrapper (no longer used by new approach). |
| autolens/plot/init.py | Reworked exports toward standalone subplot helpers and low-level wrappers. |
| autolens/lens/tracer_util.py | Added critical_curves_from, caustics_from, lines_of_planes_from. |
| autolens/lens/subhalo.py | Removed SubhaloPlotter class (replaced by standalone plot modules). |
| autolens/lens/sensitivity.py | Removed SubhaloSensitivityPlotter class (replaced by standalone plot modules). |
| autolens/lens/plot/tracer_plotters.py | Deleted tracer plotter class in favor of standalone plotting functions. |
| autolens/lens/plot/tracer_plots.py | New standalone tracer subplot helpers. |
| autolens/lens/plot/subhalo_plots.py | New standalone subplot helpers for subhalo visualization. |
| autolens/lens/plot/sensitivity_plots.py | New standalone subplot helpers for sensitivity visualization. |
| autolens/interferometer/plot/fit_interferometer_plotters.py | Deleted interferometer plotter class in favor of standalone plotting functions. |
| autolens/interferometer/plot/fit_interferometer_plots.py | New standalone interferometer subplot helpers. |
| autolens/interferometer/model/visualizer.py | Removed passing of visuals_2d_of_planes_list into interfaces. |
| autolens/interferometer/model/plotter_interface.py | Updated interface to call new interferometer subplot helpers. |
| autolens/imaging/plot/fit_imaging_plotters.py | Deleted imaging plotter class in favor of standalone plotting functions. |
| autolens/imaging/model/visualizer.py | Removed passing of visuals_2d_of_planes_list into interfaces. |
| autolens/imaging/model/plotter_interface.py | Updated interface to call new imaging subplot helpers. |
| autolens/analysis/plotter_interface.py | Updated tracer + positions plotting to use standalone functions. |
| PLOT_REFACTOR_PLAN.md | Added detailed multi-PR plan/documentation for the broader refactor. |
| .gitignore | Added autolens_workspace_test/ ignore entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| output_path = str(self.image_path) | ||
| fmt = self.fmt | ||
|
|
||
| plane_indexes_to_plot = [i for i in fit.tracer.plane_indexes_with_images if i != 0] | ||
|
|
||
| if should_plot("subplot_fit") or quick_update: | ||
|
|
||
| if len(fit.tracer.planes) > 2: | ||
| for plane_index in plane_indexes_to_plot: | ||
| subplot_fit(fit, output_path=output_path, output_format=fmt, | ||
| plane_index=plane_index) | ||
| else: | ||
| subplot_fit(fit, output_path=output_path, output_format=fmt) | ||
|
|
There was a problem hiding this comment.
Like other interfaces, fmt = self.fmt is passed through to subplot helpers; _save_subplot supports list/tuple formats, but lower-level plot functions likely expect a single string format. Normalize fmt to a string before calling subplot_fit* / subplot_of_planes helpers (or make the helpers normalize internally).
| _to_lines, | ||
| _save_subplot, | ||
| _critical_curves_from, |
There was a problem hiding this comment.
Unused imports (_to_lines, _critical_curves_from) are pulled from autolens.plot.plot_utils but never referenced in this module. Removing them will keep the plotting helper focused and avoid implying overlay logic that isn’t actually used.
| _to_lines, | |
| _save_subplot, | |
| _critical_curves_from, | |
| _save_subplot, |
| keywords = ["cli"] | ||
| dependencies = [ | ||
| "autogalaxy", | ||
| "autogalaxy @ git+https://github.com/Jammy2211/PyAutoGalaxy.git@claude/refactor-plotting-module-3ZdD8", |
There was a problem hiding this comment.
autogalaxy is now pulled from a Git URL pinned to a branch name. This makes installs non-reproducible (branch can move) and can break downstream packaging. Prefer pinning to an immutable commit SHA or a released version/tag, and (if needed) move this override into a dev-only constraints file.
| "autogalaxy @ git+https://github.com/Jammy2211/PyAutoGalaxy.git@claude/refactor-plotting-module-3ZdD8", | |
| "autogalaxy @ git+https://github.com/Jammy2211/PyAutoGalaxy.git@97b6c2f4b0e4c2b2d3a1c4e5f6a7b8c9d0e1f2a", |
| output_path = str(self.image_path) | ||
| fmt = self.fmt | ||
|
|
||
| if should_plot("subplot_dataset"): | ||
| subplot_dataset(dataset, output_path=output_path, output_format=fmt) |
There was a problem hiding this comment.
fmt = self.fmt may be a list/tuple of formats (handled elsewhere via _save_subplot). Passing it through to subplot_dataset(..., output_format=fmt) risks sending a list into lower-level plot functions that expect a string format. Normalize to a single string (e.g. first entry) before calling subplot helpers, or update helpers to accept list/tuple consistently.
| return plot_setting(section="tracer", name=name) | ||
|
|
||
| output_path = str(self.image_path) | ||
| fmt = self.fmt |
There was a problem hiding this comment.
fmt = self.fmt may be a list/tuple of formats, but it’s passed directly into the subplot helpers. If fmt is not a plain string this can break lower-level plot calls that expect a single format. Normalize fmt (e.g. first entry) before passing it down, or update the subplot helpers to accept list/tuple formats consistently.
| fmt = self.fmt | |
| fmt = self.fmt | |
| if isinstance(fmt, (list, tuple)): | |
| fmt = fmt[0] if fmt else None |
| import matplotlib.pyplot as plt | ||
| import numpy as np |
There was a problem hiding this comment.
matplotlib.pyplot and numpy are imported but not used in this module. Removing unused imports avoids confusion and keeps the module focused on orchestration.
| import matplotlib.pyplot as plt | |
| import numpy as np |
| output_path = str(self.image_path) | ||
| fmt = self.fmt | ||
|
|
||
| if should_plot("subplot_fit") or quick_update: | ||
| subplot_fit_point(fit, output_path=output_path, output_format=fmt) | ||
|
|
There was a problem hiding this comment.
Same self.fmt issue here: subplot_fit_point(..., output_format=fmt) can propagate a list/tuple format into the plotting helpers. Normalize fmt to a string before calling, or make the helper functions robust to list/tuple formats.
| def subplot_fit( | ||
| fit, | ||
| output_path: Optional[str] = None, | ||
| output_format: str = "png", | ||
| ): | ||
| """Subplot of a FitPointDataset: positions panel and (optionally) fluxes panel.""" | ||
| from autoarray.plot.plots.grid import plot_grid | ||
| from autoarray.plot.plots.yx import plot_yx | ||
|
|
||
| has_fluxes = fit.dataset.fluxes is not None | ||
| n = 2 if has_fluxes else 1 | ||
|
|
||
| fig, axes = plt.subplots(1, n, figsize=(7 * n, 7)) | ||
| axes_flat = [axes] if n == 1 else list(np.array(axes).flatten()) | ||
|
|
||
| # Positions panel | ||
| obs_grid = np.array( | ||
| fit.dataset.positions.array | ||
| if hasattr(fit.dataset.positions, "array") | ||
| else fit.dataset.positions | ||
| ) | ||
| model_grid = np.array( | ||
| fit.positions.model_data.array | ||
| if hasattr(fit.positions.model_data, "array") | ||
| else fit.positions.model_data | ||
| ) | ||
|
|
||
| plot_grid( | ||
| grid=obs_grid, | ||
| ax=axes_flat[0], | ||
| title=f"{fit.dataset.name} Fit Positions", | ||
| output_path=None, | ||
| output_filename=None, | ||
| output_format=output_format, | ||
| ) | ||
| axes_flat[0].scatter(model_grid[:, 1], model_grid[:, 0], c="r", s=20, zorder=5) | ||
|
|
||
| # Fluxes panel | ||
| if has_fluxes and n > 1: | ||
| y = np.array(fit.dataset.fluxes) | ||
| x = np.arange(len(y)) | ||
| plot_yx( | ||
| y=y, | ||
| x=x, | ||
| ax=axes_flat[1], | ||
| title=f"{fit.dataset.name} Fit Fluxes", | ||
| output_path=None, | ||
| output_filename="fit_point_fluxes", | ||
| output_format=output_format, | ||
| ) |
There was a problem hiding this comment.
Same output_format robustness issue here: the subplot passes output_format into autoarray.plot.plots.grid/plot_yx, which likely expects a string. If callers pass a list/tuple (supported by _save_subplot), this can raise. Normalize output_format to a string for the low-level plot calls.
autolens/plot/plot_utils.py
Outdated
| def plot_array( | ||
| array, | ||
| ax=None, | ||
| title="", | ||
| lines=None, | ||
| positions=None, | ||
| colormap="jet", | ||
| use_log10=False, | ||
| vmin=None, | ||
| vmax=None, | ||
| output_path=None, | ||
| output_filename="array", | ||
| output_format="png", | ||
| ): | ||
| """Plot an Array2D (or numpy array) using autoarray's low-level plot_array. | ||
|
|
||
| When *ax* is provided the figure is rendered into that axes object (subplot | ||
| mode) and no file is written. When *ax* is ``None`` the figure is saved to | ||
| *output_path/output_filename.output_format* (standalone mode). | ||
| """ | ||
| from autoarray.plot.plots.array import plot_array as _aa_plot_array | ||
| from autoarray.structures.plot.structure_plotters import ( | ||
| _auto_mask_edge, | ||
| _numpy_lines, | ||
| _numpy_positions, | ||
| _zoom_array, | ||
| ) | ||
|
|
||
| array = _zoom_array(array) | ||
|
|
||
| try: | ||
| arr = array.native.array | ||
| extent = array.geometry.extent | ||
| except AttributeError: | ||
| arr = np.asarray(array) | ||
| extent = None | ||
|
|
||
| mask = _auto_mask_edge(array) if hasattr(array, "mask") else None | ||
| _lines = lines if isinstance(lines, list) else _numpy_lines(lines) | ||
| _positions = ( | ||
| positions if isinstance(positions, list) else _numpy_positions(positions) | ||
| ) | ||
|
|
||
| _aa_plot_array( | ||
| array=arr, | ||
| ax=ax, | ||
| extent=extent, | ||
| mask=mask, | ||
| positions=_positions, | ||
| lines=_lines, | ||
| title=title, | ||
| colormap=colormap, | ||
| use_log10=use_log10, | ||
| vmin=vmin, | ||
| vmax=vmax, | ||
| output_path=output_path if ax is None else None, | ||
| output_filename=output_filename, | ||
| output_format=output_format, | ||
| structure=array, | ||
| ) |
There was a problem hiding this comment.
plot_array forwards output_format directly to autoarray’s low-level plot_array. However _save_subplot explicitly supports output_format being a list/tuple, and callers pass self.fmt around. If a list/tuple reaches here, the low-level plot function may fail. Consider normalizing output_format to a single string before calling _aa_plot_array (while keeping list/tuple support for the final fig.savefig paths).
autolens/plot/plot_utils.py
Outdated
| def plot_grid( | ||
| grid, | ||
| ax=None, | ||
| title="", | ||
| output_path=None, | ||
| output_filename="grid", | ||
| output_format="png", | ||
| ): | ||
| """Plot a Grid2D using autoarray's low-level plot_grid.""" | ||
| from autoarray.plot.plots.grid import plot_grid as _aa_plot_grid | ||
|
|
||
| _aa_plot_grid( | ||
| grid=np.array(grid.array), | ||
| ax=ax, | ||
| title=title, | ||
| output_path=output_path if ax is None else None, | ||
| output_filename=output_filename, | ||
| output_format=output_format, | ||
| ) |
There was a problem hiding this comment.
plot_grid assumes grid has an .array attribute (np.array(grid.array)). This will raise if callers pass an already-numpy grid (which happens in the new subplot helpers). Consider handling both cases (e.g. np.array(grid.array) if hasattr(grid, 'array') else np.asarray(grid)).
The stale `imaging` entry in .gitignore silently prevented autolens/imaging/plot/fit_imaging_plots.py and its test file from ever being committed, causing ModuleNotFoundError on fresh clones. - Remove `imaging` from .gitignore (was a legacy leftover) - Add autolens/imaging/plot/fit_imaging_plots.py (was on disk, never staged) - Add test_autolens/imaging/plot/test_fit_imaging_plots.py (same issue) All 173 tests pass. https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
…re_array - Delete _plot_with_vmax, _plot_with_vmin, _plot_with_vmin_vmax, _plot_symmetric from fit_imaging_plots.py — callers now pass vmin/vmax directly to plot_array - Add _symmetric_vmax() helper in fit_imaging_plots.py to compute abs-max for symmetric colormap scaling - Add _prepare_array() to plot_utils.py: handles zoom, Array2D→numpy extraction, and mask derivation in one place - Rewrite plot_array and plot_grid in plot_utils.py as thin adapters that use _prepare_array then delegate entirely to autoarray's low-level functions https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
The installed autoarray version exports Cmap/Colorbar/Output directly from autoarray.plot.wrap, not from the wrap.base subpackage. https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
…ectly - Strip plot_utils.py down to autolens-specific utilities only: _to_lines, _to_positions, _save_subplot, _critical_curves_from, _caustics_from. - Remove _zoom_array, _auto_mask_edge, _numpy_lines, _numpy_positions, _prepare_array — these are now handled inside autoarray's plot_array/ plot_grid directly (Array2D/Grid2D objects accepted natively). - Remove plot_array and plot_grid adapter functions from plot_utils.py. - All callers now import plot_array from autoarray.plot.plots.array and plot_grid from autoarray.plot.plots.grid. - plot/__init__.py re-exports plot_array/plot_grid from autoarray. - fit_imaging_plots.py uses _zoom_array_2d from autoarray for _symmetric_vmax computation. https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
- Remove _save_subplot from plot_utils.py (now just 3 autolens-specific helpers: _to_lines, _critical_curves_from, _caustics_from) - All callers now import save_figure from autoarray.plot.plots.utils - autoarray's save_figure updated to accept format as list or single string https://claude.ai/code/session_01CzJBy8KvFXiNchoNdk5i9k
…bar/Output autoarray.plot.wrap subpackage may not exist on all installed versions; autoarray.plot re-exports all wrap classes directly and is always available.
These wrap classes may not exist in all autoarray versions; users can import them directly from autoarray if needed.
This pull request refactors how overlays (such as critical curves and caustics) are handled in plotting interfaces for imaging and analysis. The main improvement is the replacement of the
visuals_2d_of_planes_listapproach with a more flexible and explicit system using line overlays, which simplifies the plotting logic and makes overlays per plane more transparent. It also removes unused or redundant parameters and code, leading to a cleaner and more maintainable codebase.Key changes include:
Refactoring of Overlays and Visuals Handling:
visuals_2d_of_planes_listwith explicit handling of line overlays per plane (critical curves and caustics) via a new propertylines_of_planesinFitImagingPlotter. This improves clarity and flexibility for overlaying features in plots. [1] [2]fit_imaging_plotters.pyto use the newlinesargument instead ofvisuals_2d, and removed related logic for setting visuals. [1] [2] [3] [4]API and Parameter Cleanup:
visuals_2d_of_planes_listparameter from multiple methods and classes in bothplotter_interface.pyandvisualizer.py, simplifying method signatures and reducing unnecessary complexity. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Internal Logic and Import Adjustments:
tracer_util.visuals_2d_of_planes_list_fromand unusedsource_plane_mesh_indexeslogic. [1] [2] [3]plotter_interface.pyby directly passing position arrays for plotting, instead of wrapping them inVisuals2D.These changes collectively make the plotting code more modular, easier to understand, and maintain, while providing more explicit control over overlay features in lensing plots.