Skip to content

Commit c87c782

Browse files
authored
Merge pull request #265 from PyAutoLabs/feature/test-mode-separate
refactor: rename env vars to PYAUTO_* prefix
2 parents 501b93a + 074eca8 commit c87c782

8 files changed

Lines changed: 17 additions & 17 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ black autoarray/
4545

4646
### Plot Output Mode
4747

48-
Set `PYAUTOARRAY_OUTPUT_MODE=1` to capture every figure produced by a script into numbered PNG files in `./output_mode/<script_name>/`. This is useful for visually inspecting all plots from an integration test without needing a display.
48+
Set `PYAUTO_OUTPUT_MODE=1` to capture every figure produced by a script into numbered PNG files in `./output_mode/<script_name>/`. This is useful for visually inspecting all plots from an integration test without needing a display.
4949

5050
```bash
51-
PYAUTOARRAY_OUTPUT_MODE=1 python scripts/my_script.py
51+
PYAUTO_OUTPUT_MODE=1 python scripts/my_script.py
5252
# -> ./output_mode/my_script/0_fit.png, 1_tracer.png, ...
5353
```
5454

autoarray/inversion/mesh/image_mesh/hilbert.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from autoarray.structures.grids.irregular_2d import Grid2DIrregular
1313

1414
from autoarray import exc
15-
from autoconf.test_mode import is_test_mode
15+
from autoconf.test_mode import skip_checks
1616

1717

1818
def gilbert2d(width, height):
@@ -331,7 +331,7 @@ def check_mesh_pixels_per_image_pixels(
331331
an exception is raised.
332332
"""
333333

334-
if is_test_mode():
334+
if skip_checks():
335335
return
336336

337337
if image_mesh_min_mesh_pixels_per_pixel is not None:
@@ -398,7 +398,7 @@ def check_adapt_background_pixels(
398398
an exception is raised.
399399
"""
400400

401-
if is_test_mode():
401+
if skip_checks():
402402
return
403403

404404
if image_mesh_adapt_background_percent_threshold is not None:

autoarray/mask/mask_2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def circular(
360360
and visa versa.
361361
"""
362362

363-
if os.environ.get("PYAUTO_WORKSPACE_SMALL_DATASETS") == "1":
363+
if os.environ.get("PYAUTO_SMALL_DATASETS") == "1":
364364
if shape_native[0] > 15 or shape_native[1] > 15:
365365
shape_native = (15, 15)
366366
pixel_scales = 0.6

autoarray/operators/over_sampling/over_sample_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def over_sample_size_via_radial_bins_from(
232232
"""
233233
Returns an adaptive sub-grid size based on the radial distance of every pixel from the centre of the mask.
234234
235-
When ``PYAUTO_WORKSPACE_SMALL_DATASETS=1`` returns a uniform size-2 array
235+
When ``PYAUTO_SMALL_DATASETS=1`` returns a uniform size-2 array
236236
immediately, skipping the expensive radial-bin computation and numba JIT.
237237
238238
The adaptive sub-grid size is computed as follows:
@@ -269,7 +269,7 @@ def over_sample_size_via_radial_bins_from(
269269

270270
import os
271271

272-
if os.environ.get("PYAUTO_WORKSPACE_SMALL_DATASETS") == "1":
272+
if os.environ.get("PYAUTO_SMALL_DATASETS") == "1":
273273
return Array2D(values=np.full(grid.shape_slim, 2.0), mask=grid.mask)
274274

275275
if centre_list is None:

autoarray/plot/output.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def to_figure(
193193
os.makedirs(output_path, exist_ok=True)
194194

195195
if not self.bypass:
196-
if os.environ.get("PYAUTOARRAY_OUTPUT_MODE") == "1":
196+
if os.environ.get("PYAUTO_OUTPUT_MODE") == "1":
197197
return self.to_figure_output_mode(filename=filename)
198198

199199
if format == "show":
@@ -222,7 +222,7 @@ def subplot_to_figure(
222222
if format != "show":
223223
os.makedirs(output_path, exist_ok=True)
224224

225-
if os.environ.get("PYAUTOARRAY_OUTPUT_MODE") == "1":
225+
if os.environ.get("PYAUTO_OUTPUT_MODE") == "1":
226226
return self.to_figure_output_mode(filename=filename)
227227

228228
if format == "show":
@@ -237,7 +237,7 @@ def to_figure_output_mode(self, filename: str):
237237
"""Save the current figure as a numbered PNG snapshot in *output mode*.
238238
239239
Output mode is activated by setting the environment variable
240-
``PYAUTOARRAY_OUTPUT_MODE=1``. Each call increments a global counter
240+
``PYAUTO_OUTPUT_MODE=1``. Each call increments a global counter
241241
so that figures are saved as ``0_filename.png``, ``1_filename.png``,
242242
etc. in a sub-directory named after the running script. This is useful
243243
for collecting a sequence of figures during automated testing or

autoarray/plot/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,13 @@ def set_with_color_values(ax, cmap, color_values, norm=None):
299299
def _output_mode_save(fig, filename):
300300
import matplotlib.pyplot as plt
301301

302-
"""If ``PYAUTOARRAY_OUTPUT_MODE=1``, save *fig* to a numbered file in
302+
"""If ``PYAUTO_OUTPUT_MODE=1``, save *fig* to a numbered file in
303303
``./output_mode/<script_name>/`` and return ``True``. Otherwise return
304304
``False`` so the caller can proceed with normal saving.
305305
306306
The counter is stored as a function attribute to avoid a global variable.
307307
"""
308-
if os.environ.get("PYAUTOARRAY_OUTPUT_MODE") != "1":
308+
if os.environ.get("PYAUTO_OUTPUT_MODE") != "1":
309309
return False
310310

311311
import sys

autoarray/structures/grids/uniform_2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def __init__(
171171

172172
grid_2d_util.check_grid_2d(grid_2d=values)
173173

174-
if os.environ.get("PYAUTO_WORKSPACE_SMALL_DATASETS") == "1":
174+
if os.environ.get("PYAUTO_SMALL_DATASETS") == "1":
175175
over_sample_size = 2
176176

177177
self._over_sample_size = over_sample_size
@@ -490,7 +490,7 @@ def uniform(
490490
origin
491491
The origin of the grid's mask.
492492
"""
493-
if os.environ.get("PYAUTO_WORKSPACE_SMALL_DATASETS") == "1":
493+
if os.environ.get("PYAUTO_SMALL_DATASETS") == "1":
494494
if shape_native[0] > 15 or shape_native[1] > 15:
495495
shape_native = (15, 15)
496496
pixel_scales = 0.6

autoarray/util/dataset_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def should_simulate(dataset_path):
66
"""
77
Returns True if the dataset at ``dataset_path`` needs to be simulated.
88
9-
When ``PYAUTO_WORKSPACE_SMALL_DATASETS=1`` is active, any existing dataset
9+
When ``PYAUTO_SMALL_DATASETS=1`` is active, any existing dataset
1010
is deleted so the simulator re-creates it at the reduced resolution. This
1111
avoids shape mismatches between full-resolution FITS files on disk and the
1212
15x15 mask/grid cap applied by the env var.
@@ -17,7 +17,7 @@ def should_simulate(dataset_path):
1717
if aa.util.dataset.should_simulate(dataset_path):
1818
subprocess.run([sys.executable, "scripts/.../simulator.py"], check=True)
1919
"""
20-
if os.environ.get("PYAUTO_WORKSPACE_SMALL_DATASETS") == "1":
20+
if os.environ.get("PYAUTO_SMALL_DATASETS") == "1":
2121
if os.path.exists(dataset_path):
2222
shutil.rmtree(dataset_path)
2323

0 commit comments

Comments
 (0)