Skip to content

Commit 00a0499

Browse files
Claudeclaude
andcommitted
refactor: delegate norm_from to the shared autoarray helper (PyAutoArray#488)
`norm_from` was added by #586 as a faithful copy of the colour-norm block in autoarray's plot_array. PyAutoArray#488 makes that block one shared helper (autoarray.plot.utils.norm_from), so this becomes a thin delegate rather than a third copy: autogalaxy may import autoarray, and the name stays autogalaxy's so the Clicker/Scribbler callers added in #586 keep working unchanged. Behaviour is unchanged here — the autoarray helper's log10-floor path is the one this function already implemented. test_autogalaxy/gui/test_plot_norm.py, which pins that behaviour, is green untouched (9 passed); full suite 1119 passed, 1 skipped against the PyAutoArray#488 branch. Library-first: PyAutoArray#488 merges before this. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DamasCoRrENvgiRkU5WHHW
1 parent d68a8f6 commit 00a0499

1 file changed

Lines changed: 9 additions & 32 deletions

File tree

‎autogalaxy/util/plot_utils.py‎

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,17 @@ def norm_from(array, use_log10=False, vmin=None, vmax=None):
133133
``plot_*`` functions do, without needing a plotter object that the public
134134
namespaces no longer export.
135135
136-
The behaviour mirrors the normalisation applied inside
137-
``autoarray.plot.array.plot_array``.
136+
The behaviour is not defined here: this is a thin delegate to
137+
``autoarray.plot.utils.norm_from``, the one implementation every PyAuto
138+
colour scale is built from. It used to be a third copy of that logic, and
139+
the copies had diverged — see the autoarray helper's docstring for the
140+
behaviour and for which divergence was resolved which way. Only the name
141+
is autogalaxy's, so the GUI callers keep working.
138142
139143
Parameters
140144
----------
141145
array
142-
The image being normalised. Only read when *use_log10* is ``True`` and
146+
The values being coloured. Only read when *use_log10* is ``True`` and
143147
no explicit *vmax* is given.
144148
use_log10
145149
When ``True`` a ``LogNorm`` is applied, with values clipped at the
@@ -152,36 +156,9 @@ def norm_from(array, use_log10=False, vmin=None, vmax=None):
152156
-------
153157
matplotlib.colors.Normalize or None
154158
"""
155-
if use_log10:
156-
try:
157-
from autonerves import conf as _conf
158-
159-
log10_min = _conf.instance["visualize"]["general"]["general"][
160-
"log10_min_value"
161-
]
162-
except Exception:
163-
log10_min = 1.0e-4
164-
165-
clipped = np.clip(array, log10_min, None)
166-
vmin_log = vmin if (vmin is not None and np.isfinite(vmin)) else log10_min
167-
if vmax is not None and np.isfinite(vmax):
168-
vmax_log = vmax
169-
else:
170-
with np.errstate(all="ignore"):
171-
vmax_log = np.nanmax(clipped)
172-
if not np.isfinite(vmax_log) or vmax_log <= vmin_log:
173-
vmax_log = vmin_log * 10.0
174-
175-
from matplotlib.colors import LogNorm
176-
177-
return LogNorm(vmin=vmin_log, vmax=vmax_log)
178-
179-
if vmin is not None or vmax is not None:
180-
from matplotlib.colors import Normalize
181-
182-
return Normalize(vmin=vmin, vmax=vmax)
159+
from autoarray.plot.utils import norm_from as _norm_from
183160

184-
return None
161+
return _norm_from(array=array, use_log10=use_log10, vmin=vmin, vmax=vmax)
185162

186163

187164
def _resolve_format(output_format):

0 commit comments

Comments
 (0)