The codebase is in a partial refactoring state. Standalone plot_array, plot_grid,
plot_yx, plot_inversion_reconstruction functions already exist in
autoarray/plot/plots/ and are called by the new-style plotters. However:
Visuals1DandVisuals2Dwrapper classes still exist- Every plotter still accepts
visuals_2d/visuals_1dconstructor args and stores them - Helper functions (
_lines_from_visuals,_positions_from_visuals,_mask_edge_from,_grid_from_visuals) bridge old Visuals → new standalone functions MatPlot2D.plot_array/plot_grid/plot_mapperandMatPlot1D.plot_yxstill exist andInterferometerPlotterstill calls them directlyInversionPlotter.subplot_of_mapperdirectly mutatesself.visuals_2d
Remove Visuals1D, Visuals2D, and AbstractVisuals entirely. Each plotter holds its
overlay data as plain attributes and passes them straight to the plot_* standalone
functions. Default overlays (e.g. mask derived from array.mask) are computed inline.
- Remove
visuals_1d: Visuals1Dandvisuals_2d: Visuals2Dconstructor parameters and their default instantiation (self.visuals_1d = visuals_1d or Visuals1D(), etc.) - Remove the imports of
Visuals1DandVisuals2D
Replace visuals_2d: Visuals2D = None with explicit per-overlay kwargs. Plotters store
each overlay as a plain instance attribute (defaulting to None).
Array2DPlotter (structures/plot/structure_plotters.py):
def __init__(self, array, mat_plot_2d=None,
mask=None, origin=None, border=None, grid=None,
positions=None, lines=None, vectors=None,
patches=None, fill_region=None, array_overlay=None):Grid2DPlotter:
def __init__(self, grid, mat_plot_2d=None, lines=None, positions=None):YX1DPlotter:
def __init__(self, y, x=None, mat_plot_1d=None,
shaded_region=None, vertical_line=None, points=None, ...):MapperPlotter (inversion/plot/mapper_plotters.py):
def __init__(self, mapper, mat_plot_2d=None,
lines=None, grid=None, positions=None):InversionPlotter (inversion/plot/inversion_plotters.py):
def __init__(self, inversion, mat_plot_2d=None,
lines=None, grid=None, positions=None,
residuals_symmetric_cmap=True):ImagingPlotterMeta / ImagingPlotter (dataset/plot/imaging_plotters.py):
def __init__(self, dataset, mat_plot_2d=None,
mask=None, grid=None, positions=None, lines=None):FitImagingPlotterMeta / FitImagingPlotter (fit/plot/fit_imaging_plotters.py):
def __init__(self, fit, mat_plot_2d=None,
mask=None, grid=None, positions=None, lines=None,
residuals_symmetric_cmap=True):InterferometerPlotter (dataset/plot/interferometer_plotters.py):
def __init__(self, dataset, mat_plot_1d=None, mat_plot_2d=None, lines=None):Each plotter's internal plot helpers already call the standalone functions. Replace calls like:
mask=_mask_edge_from(array, self.visuals_2d),
lines=_lines_from_visuals(self.visuals_2d),with direct access to the plotter's own attributes plus inline auto-extraction:
mask=self.mask if self.mask is not None else _auto_mask_edge(array),
lines=self.lines,Where _auto_mask_edge(array) is a tiny module-level helper (no Visuals dependency):
def _auto_mask_edge(array):
"""Return edge-pixel (y,x) coords from array.mask, or None."""
try:
if not array.mask.is_all_false:
return np.array(array.mask.derive_grid.edge.array)
except AttributeError:
pass
return NoneCurrently this method does:
self.visuals_2d += Visuals2D(mesh_grid=mapper.image_plane_mesh_grid)Replace by passing mesh_grid directly to the specific figures_2d_of_pixelization
call that needs it, or by temporarily storing self.mesh_grid on the plotter and
checking it in _plot_array. The mutation and the Visuals2D(...) construction are
both removed.
Similarly remove self.visuals_2d.indexes = indexes in subplot_mappings — store as
self._indexes and pass through.
InterferometerPlotter still calls self.mat_plot_2d.plot_array(...),
self.mat_plot_2d.plot_grid(...), and self.mat_plot_1d.plot_yx(...).
Replace each with the equivalent standalone function call, deriving ax, output_path,
filename, fmt via _output_for_mat_plot (which already exists and has no Visuals
dependency).
Once no caller uses them, delete these methods from mat_plot/two_d.py:
plot_arrayplot_gridplot_mapper_plot_rectangular_mapper_plot_delaunay_mapper
Remove the from autoarray.plot.visuals.two_d import Visuals2D import.
Delete the method from mat_plot/one_d.py and remove the Visuals1D import.
Delete (no longer needed):
_lines_from_visuals_positions_from_visuals_mask_edge_from_grid_from_visuals
Keep: _zoom_array, _output_for_mat_plot (neither depends on Visuals).
Remove:
autoarray/plot/visuals/__init__.pyautoarray/plot/visuals/abstract.pyautoarray/plot/visuals/one_d.pyautoarray/plot/visuals/two_d.py
Remove Visuals1D and Visuals2D exports (lines 45–46).
Read and update:
fit/plot/fit_interferometer_plotters.pyfit/plot/fit_vector_yx_plotters.py
Both import Visuals1D/Visuals2D; apply the same pattern as above.
python -m pytest test_autoarray/ -q --tb=shortFix any failures before committing.
| File | Change |
|---|---|
autoarray/plot/abstract_plotters.py |
Remove visuals_1d, visuals_2d |
autoarray/plot/mat_plot/one_d.py |
Remove plot_yx, remove Visuals1D import |
autoarray/plot/mat_plot/two_d.py |
Remove plot_array/grid/mapper methods, remove Visuals2D import |
autoarray/plot/visuals/ |
Delete entire directory |
autoarray/plot/__init__.py |
Remove Visuals exports |
autoarray/structures/plot/structure_plotters.py |
Replace visuals args with individual kwargs; remove helper functions |
autoarray/inversion/plot/mapper_plotters.py |
Replace visuals args with individual kwargs |
autoarray/inversion/plot/inversion_plotters.py |
Replace visuals args; fix subplot_of_mapper mutation |
autoarray/dataset/plot/imaging_plotters.py |
Replace visuals args with individual kwargs |
autoarray/dataset/plot/interferometer_plotters.py |
Replace visuals args; replace old MatPlot calls |
autoarray/fit/plot/fit_imaging_plotters.py |
Replace visuals args with individual kwargs |
autoarray/fit/plot/fit_interferometer_plotters.py |
Replace visuals args |
autoarray/fit/plot/fit_vector_yx_plotters.py |
Replace visuals args |