refactor: remove the duplicate autogalaxy/plot/plot_utils.py - #584
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
autogalaxy/util/plot_utils.pyandautogalaxy/plot/plot_utils.pywere byte-identical — md5a6eed88a228524d55403418fdf01d32a— both defining the plot andfits_arrayhelpers.util/is the real home:autogalaxy/plot/__init__.py:9imports the publicplot_array/plot_grid/fits_arrayfromutil/autogalaxyimport itplot/plot_utils.pyhad 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_utilswas never part of the public namespace.ag.plot.plot_array,ag.plot.plot_gridandag.plot.fits_arrayall resolve throughutil/and are untouched. Nothing importable asag.*is removed.Test Plan
python -m pytest test_autogalaxy/— 1099 passed, 5 skippedmainbefore the change — 1099 passed, 5 skippedautogalaxy.plot.plot_utilsacross PyAutoGalaxy, PyAutoLens, PyAutoFit, PyAutoArray, PyAutoNerves, autolens_workspace and autogalaxy_workspaceA 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 attest_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 atutil/.util/plot_utils.py— drops a stray/btw okline sitting inside the_critical_curves_fromdocstring. It arrived in3ca31bf(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