From 77686676410b871005677cb0c393506f251dfd3e Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 6 Apr 2026 21:03:04 +0100 Subject: [PATCH] feat: add PYAUTO_WORKSPACE_SMALL_DATASETS env var to cap grid/mask size When PYAUTO_WORKSPACE_SMALL_DATASETS=1, Grid2D.uniform() and Mask2D.circular() override shape_native to (15, 15) and pixel_scales to 0.6 for any grid larger than 15x15. This makes workspace smoke tests dramatically faster by reducing all downstream computations (DFT, ray-tracing, plotting) without any changes to workspace scripts. Co-Authored-By: Claude Opus 4.6 (1M context) --- autoarray/mask/mask_2d.py | 6 ++++++ autoarray/structures/grids/uniform_2d.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/autoarray/mask/mask_2d.py b/autoarray/mask/mask_2d.py index 1fd5e722..c5a78ff0 100644 --- a/autoarray/mask/mask_2d.py +++ b/autoarray/mask/mask_2d.py @@ -1,5 +1,6 @@ from __future__ import annotations import logging +import os from enum import Enum import numpy as np from pathlib import Path @@ -359,6 +360,11 @@ def circular( and visa versa. """ + if os.environ.get("PYAUTO_WORKSPACE_SMALL_DATASETS") == "1": + if shape_native[0] > 15 or shape_native[1] > 15: + shape_native = (15, 15) + pixel_scales = 0.6 + pixel_scales = geometry_util.convert_pixel_scales_2d(pixel_scales=pixel_scales) mask = mask_2d_util.mask_2d_circular_from( diff --git a/autoarray/structures/grids/uniform_2d.py b/autoarray/structures/grids/uniform_2d.py index 975e04ad..80bccfe7 100644 --- a/autoarray/structures/grids/uniform_2d.py +++ b/autoarray/structures/grids/uniform_2d.py @@ -1,4 +1,5 @@ from __future__ import annotations +import os import numpy as np from pathlib import Path from typing import List, Optional, Tuple, Union @@ -486,6 +487,11 @@ def uniform( origin The origin of the grid's mask. """ + if os.environ.get("PYAUTO_WORKSPACE_SMALL_DATASETS") == "1": + if shape_native[0] > 15 or shape_native[1] > 15: + shape_native = (15, 15) + pixel_scales = 0.6 + pixel_scales = geometry_util.convert_pixel_scales_2d(pixel_scales=pixel_scales) grid_slim = grid_2d_util.grid_2d_slim_via_shape_native_from(