Skip to content

PR G1-G2: replace mat_plot_2d.plot_array with _plot_array() bridge in…#306

Merged
Jammy2211 merged 27 commits intomainfrom
claude/refactor-plotting-module-3ZdD8
Mar 24, 2026
Merged

PR G1-G2: replace mat_plot_2d.plot_array with _plot_array() bridge in…#306
Jammy2211 merged 27 commits intomainfrom
claude/refactor-plotting-module-3ZdD8

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

… all plotters

  • Add autogalaxy/plot/plots/overlays.py with helpers to extract critical curves, caustics, and profile centres from Visuals2D as plain arrays
  • Add _plot_array() and _plot_grid() bridge methods to the Plotter base class that route to the new direct-matplotlib plot_array()/plot_grid() functions
  • Update all autogalaxy plotters to use self._plot_array() instead of self.mat_plot_2d.plot_array(), covering: LightProfilePlotter, BasisPlotter, MassPlotter, GalaxyPlotter, GalaxiesPlotter, AdaptPlotter, FitImagingPlotter, FitEllipsePlotter, FitEllipsePDFPlotter
  • Remove redundant (and incorrect) cmap vmin/vmax mutation in FitImagingPlotter.figures_2d_of_galaxies before subtracted_image plot

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k

Jammy2211 and others added 2 commits March 13, 2026 17:36
Split multi-scenario test functions into individual focused tests, each
testing one specific configuration. Renamed test functions to be more
descriptive. No test logic or values were changed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… all plotters

- Add autogalaxy/plot/plots/overlays.py with helpers to extract critical
  curves, caustics, and profile centres from Visuals2D as plain arrays
- Add _plot_array() and _plot_grid() bridge methods to the Plotter base class
  that route to the new direct-matplotlib plot_array()/plot_grid() functions
- Update all autogalaxy plotters to use self._plot_array() instead of
  self.mat_plot_2d.plot_array(), covering: LightProfilePlotter, BasisPlotter,
  MassPlotter, GalaxyPlotter, GalaxiesPlotter, AdaptPlotter,
  FitImagingPlotter, FitEllipsePlotter, FitEllipsePDFPlotter
- Remove redundant (and incorrect) cmap vmin/vmax mutation in
  FitImagingPlotter.figures_2d_of_galaxies before subtracted_image plot

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors Autogalaxy plotters to route common plotting calls through new Plotter helper methods, and introduces new utilities intended to convert Visuals2D overlay data into plain NumPy arrays for future plotting backends.

Changes:

  • Add _plot_array() / _plot_grid() bridge methods to Plotter and update multiple plotters to call them.
  • Add new autogalaxy.plot.plots.overlays helper functions to extract/normalize overlay data from Visuals2D.
  • Remove some plot-specific colormap min/max manipulation in FitImagingPlotter and simplify AutoLabels usage in MassPlotter.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
autogalaxy/plot/abstract_plotters.py Adds _plot_array / _plot_grid bridge methods used across plotters.
autogalaxy/profiles/plot/light_profile_plotters.py Switches image plotting to the new _plot_array helper.
autogalaxy/profiles/plot/basis_plotters.py Switches basis subplot image plotting to _plot_array.
autogalaxy/plot/mass_plotter.py Routes array plots through _plot_array and removes cb_unit from AutoLabels.
autogalaxy/imaging/plot/fit_imaging_plotters.py Uses _plot_array for galaxy image plots and removes NumPy-based vmin manipulation.
autogalaxy/galaxy/plot/galaxy_plotters.py Switches galaxy image plotting to _plot_array.
autogalaxy/galaxy/plot/galaxies_plotters.py Switches plane image/grid plotting to _plot_array / _plot_grid.
autogalaxy/galaxy/plot/adapt_plotters.py Switches adapt image plotting to _plot_array.
autogalaxy/ellipse/plot/fit_ellipse_plotters.py Switches ellipse plotting to _plot_array.
autogalaxy/plot/plots/overlays.py Adds new overlay extraction/normalization helpers (currently with correctness concerns).
autogalaxy/plot/plots/init.py Exposes the new overlay helpers via the package initializer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +15 to +33
for attr in ("tangential_critical_curves", "radial_critical_curves"):
val = getattr(visuals_2d, attr, None)
if val is None:
continue
try:
for item in val:
try:
arr = np.array(item.array if hasattr(item, "array") else item)
if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
curves.append(arr)
except Exception:
pass
except TypeError:
try:
arr = np.array(val.array if hasattr(val, "array") else val)
if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
curves.append(arr)
except Exception:
pass
Comment on lines +19 to +27
try:
for item in val:
try:
arr = np.array(item.array if hasattr(item, "array") else item)
if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
curves.append(arr)
except Exception:
pass
except TypeError:
Comment on lines +2 to +5
_critical_curves_from_visuals,
_caustics_from_visuals,
_galaxy_lines_from_visuals,
_galaxy_positions_from_visuals,
claude added 23 commits March 17, 2026 17:05
Ignores files generated by the test suite that were previously untracked:
test_autogalaxy/analysis/files/, test_autogalaxy/galaxy/files/galaxy.json,
test_autogalaxy/imaging/plot/files/, test_autogalaxy/interferometer/model/files/,
test_autogalaxy/quantity/plot/files/

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
…t overlay kwargs

- Remove Visuals1D/Visuals2D exports from autogalaxy/plot/__init__.py
- Rewrite Plotter base class to take only mat_plot_1d/mat_plot_2d (no visuals params)
- Rewrite MassPlotter with direct kwargs: positions, light_profile_centres,
  mass_profile_centres, multiple_images, tangential_critical_curves,
  radial_critical_curves; critical curves auto-computed via LensCalc when not supplied
- Rewrite all profile plotters (LightProfilePlotter, MassProfilePlotter, BasisPlotter)
  with direct overlay kwargs (half_light_radius, einstein_radius, positions, etc.)
- Rewrite galaxy plotters (GalaxyPlotter, GalaxiesPlotter, AdaptPlotter) with direct
  overlay kwargs; critical curves propagated through plotter hierarchy
- Rewrite fit plotters (FitImagingPlotter, FitInterferometerPlotter, FitQuantityPlotter,
  FitEllipsePlotter, FitEllipsePDFPlotter); internal Visuals2D constructed from kwargs
- Remove visuals_2d param from PlotterInterfaceQuantity.fit_quantity
- Update test_visuals.py to test overlay computation via MassPlotter and LensCalc
- Visuals1D/Visuals2D remain as internal implementation detail in plot/visuals/

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Replace all uses of Visuals1D/Visuals2D with direct overlay kwargs, and
switch from the removed MatPlot2D.plot_array/plot_grid methods to the new
standalone plot_array() and plot_grid() functions.

Key changes:
- abstract_plotters.py: rewrite _plot_array/_plot_grid to use standalone
  plot_array()/plot_grid() with direct lines/positions/grid kwargs
- mass_plotter.py: remove visuals_2d_with_critical_curves; expose
  tangential_critical_curves/radial_critical_curves properties directly
- visuals/two_d.py, visuals/one_d.py: emptied (classes deleted, base
  classes aplt.Visuals2D/Visuals1D no longer exist in PyAutoArray)
- fit_imaging_plotters.py: FitImagingPlotterMeta now takes positions=
  instead of visuals_2d=
- fit_interferometer_plotters.py: FitInterferometerPlotterMeta takes
  only mat_plot_1d/mat_plot_2d (no visuals at all)
- All other plotters: pass lines/positions directly instead of Visuals2D
- conftest.py: patch Figure.savefig (new save path) in addition to
  pyplot.savefig so PlotPatch test fixture still intercepts saves
- test_visuals.py: rewrite to use MassPlotter.tangential_critical_curves
  and LensCalc directly (no Visuals2D)

All 648 tests pass.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Removes all MatPlot1D/MatPlot2D/MultiFigurePlotter usage and updates to
the new PyAutoArray AbstractPlotter API (output=, cmap=, use_log10=).

Key changes:
- Remove MatPlot1D/MatPlot2D from plot/__init__.py and stub mat_plot files
- Delete mat_wrap_1d.yaml and mat_wrap_2d.yaml configs
- Rewrite abstract_plotters.py with new Plotter base class and helpers
- Update all plotter classes to use output= instead of mat_plot_2d=
- Rewrite subplot_* methods with explicit plt.subplots() + _save_subplot()
- Update all PlotterInterface classes to use output_from() instead of mat_plot_2d_from()
- Restore custom wrap classes (LightProfileCentresScatter etc.) without yaml config
- Update all test files to use new output= API

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Prepares PyAutoGalaxy for PyAutoArray's further wrap module refactor
which removes Figure, Axis, Title, Units, GridScatter, GridPlot, AXVLine,
YXScatter, FillBetween, and all other wrap objects except Cmap, Colorbar,
Output, and DelaunayDrawer.

- Remove all deleted wrap class imports from plot/__init__.py
- Update plot/wrap.py custom classes to standalone (no deleted base classes)
- Fix gui/scribbler.py cmap access to support both old and new Cmap API

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
- Remove Title import from abstract_plotters.py (Title class deleted from autoarray)
- Change title type annotation to plain str
- Clean test_autogalaxy/config/visualize.yaml: remove mat_wrap_1d and mat_wrap_2d
  sections (all entries reference deleted wrap classes) and trim mat_wrap to just
  Cmap and Colorbar entries

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
…ctions

- Delete all *_plotters.py files (LightProfilePlotter, MassProfilePlotter,
  BasisPlotter, GalaxyPlotter, GalaxiesPlotter, AdaptPlotter, FitImagingPlotter,
  FitInterferometerPlotter, FitQuantityPlotter, FitEllipsePlotter,
  FitEllipsePDFPlotter) and abstract_plotters.py / mass_plotter.py
- Add autogalaxy/plot/plot_utils.py with shared helpers: _to_lines, _to_positions,
  _save_subplot, plot_array, plot_grid, _critical_curves_from, _resolve_format
- Add *_plots.py files with standalone functions taking data objects + plain
  output_path/output_format strings instead of Output/Cmap objects:
  profiles/plot/{light_profile,mass_profile,basis}_plots.py
  galaxy/plot/{galaxy,galaxies,adapt}_plots.py
  imaging/plot/fit_imaging_plots.py
  interferometer/plot/fit_interferometer_plots.py
  quantity/plot/fit_quantity_plots.py
  ellipse/plot/fit_ellipse_plots.py
- Update autogalaxy/plot/__init__.py to export all new standalone functions
- Update all plotter_interface.py files to call new standalone functions
- Rewrite all plotter tests to use new function API
- Update test_visuals.py to use _critical_curves_from instead of MassPlotter

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
…plot_array

The 5 dedicated plot_convergence_2d/potential_2d/deflections_y_2d/
deflections_x_2d/magnification_2d wrappers are removed. Users now call
mass_profile.*_from(grid) to get an array and pass it to plot_array()
directly. subplot_of_mass_profiles in galaxy_plots.py is updated to inline
this pattern. plot_array and plot_grid are now exported from autogalaxy.plot.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Only subplot_* functions remain as public API. All standalone plot_*
wrappers that computed a single array (plot_image_2d, plot_convergence_2d,
plot_data, plot_noise_map, etc.) are removed. Users compute the array
from the object themselves and call plot_array().

- Delete light_profile_plots.py entirely
- galaxy_plots.py / galaxies_plots.py: remove all plot_* functions,
  subplots now inline array computation + plot_array calls
- adapt_plots.py: remove plot_model_image/plot_galaxy_image, inline in subplot
- fit_imaging_plots.py: remove 9 plot_* functions, keep subplot_fit/subplot_of_galaxy
- fit_quantity_plots.py: remove 6 plot_* functions, keep subplot_fit
- fit_ellipse_plots.py: make plot_data/_plot_ellipse_residuals private helpers
- autogalaxy/plot/__init__.py: only exports subplot_* functions + plot_array/plot_grid
- Rewrite all affected tests to use new pattern

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
…_.py

The autoarray refactor branch removed structure_plotters, mapper_plotters,
inversion_plotters, imaging_plotters, interferometer_plotters, and the autofit
nest/mcmc/mle plotters. These top-level imports in autogalaxy/plot/__init__.py
caused an immediate ModuleNotFoundError on import. Removed all deleted imports;
the new standalone subplot/plot_array API does not need them.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
FitImagingPlotterMeta and FitInterferometerPlotterMeta were module-level
imports in fit_imaging_plots.py, fit_interferometer_plots.py, and
fit_quantity_plots.py, causing ModuleNotFoundError on import. Rewrote
all three to use plot_array/plot_grid directly with matplotlib subplots.

Also removed deferred imports of structure_plotters helper functions from
plot_utils.py::plot_array by inlining _zoom_array, _auto_mask_edge, and
_numpy_grid locally. Fixed remaining FitImagingPlotterMeta deferred import
in imaging/model/plotter_interface.py::fit_imaging_combined.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
These plotter classes were removed from autoarray. Replace each usage
with direct matplotlib + plot_array calls:

- ImagingPlotter.subplot_dataset() -> 3-4 panel subplot (data, noise_map,
  signal_to_noise_map, psf) using plot_array
- InterferometerPlotter.subplot_dataset() -> 3-panel dirty image subplot
- InversionPlotter.subplot_of_mapper() -> scatter plot of source plane
  mesh grid colored by reconstruction values

Also remove now-unused output = self.output_from() variables in
imaging() and interferometer() methods.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
…ffix

plot_utils.plot_array now accepts vmin, vmax, and symmetric parameters,
forwarding them to the underlying autoarray plot_array. The symmetric=True
flag computes abs_max from the array and sets vmin=-abs_max, vmax=abs_max,
eliminating the need for _plot_with_v* wrapper functions in callers.

Fix inversion subplot filename: always use _{i} suffix so the output is
subplot_inversion_0.png, subplot_inversion_1.png, etc. (was omitting the
suffix for single-mapper inversions, breaking test expectations).

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
…bpackage

Replace deep submodule imports that break when autoarray.plot.plots is
removed:
  autoarray.plot.plots.array -> autoarray.plot (plot_array)
  autoarray.plot.plots.grid  -> autoarray.plot (plot_grid)
  autoarray.plot.wrap.base.cmap -> autoarray.plot (Cmap)

These are already re-exported from autoarray.plot.__init__, so the
change works on both old and new autoarray versions.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
…lign _save_subplot

- Delete autogalaxy/plot/mat_plot/ (comment-only stubs, no callers)
- Delete autogalaxy/plot/visuals/ (comment-only stubs, no callers)
- Delete autogalaxy/plot/plots/overlays.py and plots/__init__.py (no callers)
- Delete autogalaxy/plot/wrap.py (empty pass-class stubs, no callers)
- Delete test_autogalaxy/plot/mat_wrap/test_mat_obj.py (only tested stubs)
- Rewrite plot_utils.py: remove duplicated _zoom_array/_auto_mask_edge,
  import from autoarray.structures.plot.structure_plotters; align
  _save_subplot with autoarray save_figure interface (dpi, structure, FITS);
  update __init__.py to remove wrap imports

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
…ing locally

Remove _plot_visibilities_1d from fit_interferometer_plots.py and import
plot_visibilities_1d from autoarray.plot.plots.utils (where it now lives).

Also fix plot_utils.py to use _mask_edge_from(array, None) instead of the
non-existent _auto_mask_edge.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Some autoarray versions expose this via autoarray.plot.plots.utils,
others via autoarray.plot directly. Try the plots subpackage path first
and fall back to the top-level import.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Newest autoarray removes autoarray.structures.plot.structure_plotters
and autoarray.plot.plots.utils; functions are now in autoarray.plot:

- zoom_array, auto_mask_edge replace _zoom_array, _mask_edge_from
- plot_visibilities_1d is in autoarray.plot
- Cmap class removed; default colormap is "jet" string

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the PyAutoGalaxy plotting layer away from the previous Plotter/MatPlot/Visuals wrappers toward a set of direct matplotlib-backed plotting helper functions, and updates tests/config accordingly.

Changes:

  • Introduces autogalaxy.plot.plot_utils (plot_array, plot_grid, _save_subplot, and overlay/curve helpers) and switches public plotting exports to these free functions.
  • Replaces multiple Plotter-class implementations with function-based plotting modules (e.g. *_plots.py) for basis / galaxy / imaging / interferometer / quantity / ellipse plotting.
  • Updates test suite to call the new plotting functions and adjusts matplotlib savefig monkeypatching and test visualize config.

Reviewed changes

Copilot reviewed 80 out of 83 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pyproject.toml Changes autoarray dependency to a GitHub branch via VCS URL.
autogalaxy/plot/__init__.py Replaces previous plotting API exports with free-function exports.
autogalaxy/plot/plot_utils.py Adds new plotting/overlay helpers and subplot save utility.
autogalaxy/quantity/plot/fit_quantity_plots.py Adds function-based subplot plotting for FitQuantity.
autogalaxy/quantity/model/plotter_interface.py Updates plotter interface to call new fit_quantity_plots functions.
autogalaxy/profiles/plot/basis_plots.py Adds function-based basis subplot plotting.
autogalaxy/galaxy/plot/*_plots.py Adds function-based plotting for galaxies and adapt images.
autogalaxy/imaging/plot/fit_imaging_plots.py Adds function-based subplot plotting for FitImaging.
autogalaxy/interferometer/plot/fit_interferometer_plots.py Adds function-based subplot plotting for FitInterferometer.
autogalaxy/ellipse/plot/fit_ellipse_plots.py Adds function-based plotting for ellipse fit and ellipse errors.
autogalaxy/ellipse/model/plotter_interface.py Updates ellipse plotter interface to call new plotting functions.
test_autogalaxy/** Updates tests to use the new plotting functions and adjusts expectations accordingly.
test_autogalaxy/conftest.py Patches both pyplot.savefig and Figure.savefig for output interception.
test_autogalaxy/config/visualize.yaml Simplifies/removes many legacy mat_wrap config sections.
.gitignore Ignores additional generated test plot outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +5
from autogalaxy.plot.plot_utils import plot_array, plot_grid

from autogalaxy.profiles.plot.basis_plots import subplot_image as subplot_basis_image

from autogalaxy.galaxy.plot.galaxy_plots import (
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions adding autogalaxy/plot/plots/overlays.py helpers and adding _plot_array() / _plot_grid() bridge methods on a Plotter base class, but the current changeset appears to remove the Plotter-based API entirely and autogalaxy/plot now only exports free functions (and there is no plots/overlays.py in-tree). Please either update the PR description to match the implemented approach or add the missing module/bridge methods if they are still intended.

Copilot uses AI. Check for mistakes.
Comment on lines 27 to 30
dependencies = [
"autofit",
"autoarray",
"autoarray @ git+https://github.com/Jammy2211/PyAutoArray.git@claude/refactor-plotting-module-s6Zq1",
"colossus==1.3.1",
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoarray is now pulled from a GitHub branch via a direct VCS URL. This can make installs non-reproducible (branch can move / disappear) and can break downstream packaging (e.g. conda, offline builds). Prefer a released version pin (or a commit SHA if VCS is unavoidable) and document why this override is required.

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +26
def _plot_data(
fit_list: List[FitEllipse],
output_path=None,
output_filename="ellipse_fit",
output_format="png",
colormap="default",
use_log10=False,
disable_data_contours: bool = False,
suffix: str = "",
ax=None,
):
ellipse_list = []
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disable_data_contours is accepted and passed through (e.g. by subplot_fit_ellipse / PlotterInterfaceEllipse.fit_ellipse), but it is not used inside _plot_data. This means the “no data contours” behavior is currently a no-op. Either implement the contour-disabling behavior (as previously done via the MatPlot contour toggle) or remove the parameter/call-sites to avoid misleading API.

Copilot uses AI. Check for mistakes.
Comment on lines +50 to +90
def _plot_ellipse_residuals(
fit_list: List[FitEllipse],
output_path=None,
output_format="png",
for_subplot: bool = False,
suffix: str = "",
ax=None,
):
output = aplt.Output(path=output_path, format=output_format) if output_path else aplt.Output()

fit_ellipse_plot_util.plot_ellipse_residuals(
array=fit_list[0].dataset.data.native,
fit_list=fit_list,
colors="k",
output=output,
for_subplot=for_subplot,
)


def subplot_fit_ellipse(
fit_list: List[FitEllipse],
output_path=None,
output_format="png",
colormap="default",
use_log10=False,
disable_data_contours: bool = False,
):
fig, axes = plt.subplots(1, 2, figsize=(14, 7))

_plot_data(
fit_list=fit_list,
colormap=colormap,
use_log10=use_log10,
disable_data_contours=disable_data_contours,
ax=axes[0],
)
_plot_ellipse_residuals(fit_list=fit_list, for_subplot=True, ax=axes[1])

plt.tight_layout()
_save_subplot(fig, output_path, "subplot_fit_ellipse", output_format)

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subplot_fit_ellipse passes ax=axes[1] into _plot_ellipse_residuals, but _plot_ellipse_residuals ignores the ax argument. Because fit_ellipse_plot_util.plot_ellipse_residuals(..., for_subplot=True) internally calls plt.subplot(1, 2, 2), this will draw onto a new axes / the current global figure state, which can lead to incorrect subplot composition. Consider updating plot_ellipse_residuals (or _plot_ellipse_residuals) to accept and use an explicit Axes instead of creating one via plt.subplot.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +29
except Exception:
pass
else:
try:
arr = np.array(item.array if hasattr(item, "array") else item)
if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
result.append(arr)
except Exception:
pass
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_to_lines / _to_positions swallow all exceptions (except Exception: pass). This can silently drop overlays when inputs are malformed and make debugging very difficult. Consider catching only expected exceptions (e.g. TypeError, ValueError) and logging at least a debug warning with the offending type/value.

Suggested change
except Exception:
pass
else:
try:
arr = np.array(item.array if hasattr(item, "array") else item)
if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
result.append(arr)
except Exception:
pass
except (TypeError, ValueError):
logger.debug(
"_to_lines: failed to convert list element %r of type %s to array; skipping.",
sub,
type(sub),
exc_info=True,
)
else:
try:
arr = np.array(item.array if hasattr(item, "array") else item)
if arr.ndim == 2 and arr.shape[1] == 2 and len(arr) > 0:
result.append(arr)
except (TypeError, ValueError):
logger.debug(
"_to_lines: failed to convert item %r of type %s to array; skipping.",
item,
type(item),
exc_info=True,
)

Copilot uses AI. Check for mistakes.
claude added 2 commits March 24, 2026 19:17
Every public and private function in the ten plot sub-packages was missing
a docstring. This commit adds full NumPy-style docstrings covering purpose,
parameters, and return values to all functions in:

- autogalaxy/plot/plot_utils.py
- autogalaxy/galaxy/plot/galaxy_plots.py
- autogalaxy/galaxy/plot/galaxies_plots.py
- autogalaxy/galaxy/plot/adapt_plots.py
- autogalaxy/profiles/plot/basis_plots.py
- autogalaxy/imaging/plot/fit_imaging_plots.py
- autogalaxy/interferometer/plot/fit_interferometer_plots.py
- autogalaxy/quantity/plot/fit_quantity_plots.py
- autogalaxy/ellipse/plot/fit_ellipse_plot_util.py
- autogalaxy/ellipse/plot/fit_ellipse_plots.py

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
Remove the branch-pinned git URL that was added during development and
restore the standard `autoarray` dependency so the package resolves from
PyPI/the normal install path.

https://claude.ai/code/session_0154SgR1ThCsfpbMZLnbS85k
@Jammy2211 Jammy2211 merged commit bccd901 into main Mar 24, 2026
8 checks passed
@Jammy2211 Jammy2211 deleted the claude/refactor-plotting-module-3ZdD8 branch April 2, 2026 11:42
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.

3 participants