Skip to content

refactor: remove the duplicate autogalaxy/plot/plot_utils.py - #584

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/plot-utils-duplicate-modules
Aug 22, 2026
Merged

refactor: remove the duplicate autogalaxy/plot/plot_utils.py#584
Jammy2211 merged 1 commit into
mainfrom
claude/plot-utils-duplicate-modules

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

autogalaxy/util/plot_utils.py and autogalaxy/plot/plot_utils.py were byte-identical — md5 a6eed88a228524d55403418fdf01d32a — both defining the plot and fits_array helpers.

util/ is the real home:

  • autogalaxy/plot/__init__.py:9 imports the public plot_array / plot_grid / fits_array from util/
  • eight modules inside autogalaxy import it
  • PyAutoLens references it in thirteen places

plot/plot_utils.py had exactly one importer in the entire organisation, and it was a function-local import in a test. Deleted; that import re-pointed.

Found while auditing every FITS write path in the stack for PyAutoNerves#153. Both copies sat on that path, which is what made this worth doing rather than tolerating: a change applied to one copy and not the other splits behaviour between callers with nothing to catch it — separate modules, so no test compares them and no import fails.

API Changes

None — internal changes only.

autogalaxy.plot.plot_utils was never part of the public namespace. ag.plot.plot_array, ag.plot.plot_grid and ag.plot.fits_array all resolve through util/ and are untouched. Nothing importable as ag.* is removed.

Test Plan

  • python -m pytest test_autogalaxy/1099 passed, 5 skipped
  • Identical count on clean main before the change — 1099 passed, 5 skipped
  • Verified zero remaining references to autogalaxy.plot.plot_utils across PyAutoGalaxy, PyAutoLens, PyAutoFit, PyAutoArray, PyAutoNerves, autolens_workspace and autogalaxy_workspace

A note on how the one importer was found

Worth recording, because the first pass got it wrong. A static search for importers using a line-anchored pattern (^from autogalaxy.plot.plot_utils) returned zero — it silently missed the indented, function-local import at test_visuals.py:41. The deletion looked safe and wasn't; the test suite caught it immediately.

The unanchored search then found exactly one reference, which is the number this PR acts on. Anyone doing similar dead-module removal should search unanchored — Python's function-local imports don't sit at column zero.

Also in this diff

Two one-line fixes that would otherwise be left behind by the deletion:

  • galaxy/plot/galaxies_plots.py — a Sphinx cross-reference pointed at :func:~autogalaxy.plot.plot_utils._critical_curves_from``, i.e. at the module being deleted. Re-pointed at util/.
  • util/plot_utils.py — drops a stray /btw ok line sitting inside the _critical_curves_from docstring. It arrived in 3ca31bf (build: bump intra-family floors to >=2026.8.22.1 #582) and was inherited by both copies; it renders into the API docs. Removing it here rather than leaving known debris in a file this PR is already editing.

Generated by the PyAutoLabs agent workflow.


Generated by Claude Code

autogalaxy/util/plot_utils.py and autogalaxy/plot/plot_utils.py were
byte-identical (md5 a6eed88a228524d55403418fdf01d32a), both defining the plot
and fits_array helpers. util/ is the real home: autogalaxy/plot/__init__.py
imports the public plot_array / plot_grid / fits_array from it, eight modules
inside autogalaxy import it, and PyAutoLens references it in thirteen places.

Both copies sat on a FITS write path, which is what made this worth doing rather
than tolerating: a change applied to one and not the other splits behaviour
between callers with nothing to catch it -- separate modules, so no test
compares them and no import fails.

autogalaxy/plot/plot_utils.py had exactly one importer, a function-local import
in test_visuals.py, re-pointed here. Verified nothing else references it across
PyAutoGalaxy, PyAutoLens, PyAutoFit, PyAutoArray, PyAutoNerves, autolens_workspace
and autogalaxy_workspace. It was never in the public namespace -- ag.plot resolves
through util/ -- so no public symbol is removed.

Also re-points a Sphinx cross-reference in galaxies_plots.py that pointed at the
deleted module, and drops a stray "/btw ok" line that was committed into a
docstring in 3ca31bf (PR #582) and inherited by both copies.

Behaviour-preserving: test_autogalaxy is 1099 passed / 5 skipped both before and
after, an identical count.
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 22, 2026 — with Claude
@Jammy2211
Jammy2211 merged commit 506f153 into main Aug 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants