From 46aa3c737a6a82e6e939a892be47ea33d54ece8f Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 7 Apr 2026 13:52:45 +0100 Subject: [PATCH] perf: skip radial bins computation when PYAUTO_WORKSPACE_SMALL_DATASETS=1 Early-return a uniform size-2 array from over_sample_size_via_radial_bins_from(), avoiding the numba JIT compilation and radial distance computation on small test grids. Co-Authored-By: Claude Opus 4.6 (1M context) --- autoarray/operators/over_sampling/over_sample_util.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/autoarray/operators/over_sampling/over_sample_util.py b/autoarray/operators/over_sampling/over_sample_util.py index 199cfec8b..57cef6b6a 100644 --- a/autoarray/operators/over_sampling/over_sample_util.py +++ b/autoarray/operators/over_sampling/over_sample_util.py @@ -232,6 +232,9 @@ def over_sample_size_via_radial_bins_from( """ Returns an adaptive sub-grid size based on the radial distance of every pixel from the centre of the mask. + When ``PYAUTO_WORKSPACE_SMALL_DATASETS=1`` returns a uniform size-2 array + immediately, skipping the expensive radial-bin computation and numba JIT. + The adaptive sub-grid size is computed as follows: 1) Compute the radial distance of every pixel in the mask from the centre of the mask (or input centres). @@ -264,6 +267,11 @@ def over_sample_size_via_radial_bins_from( the centre of the mask. """ + import os + + if os.environ.get("PYAUTO_WORKSPACE_SMALL_DATASETS") == "1": + return Array2D(values=np.full(grid.shape_slim, 2.0), mask=grid.mask) + if centre_list is None: centre_list = [grid.mask.mask_centre]