Skip to content

Commit 2bf9ad3

Browse files
Jammy2211claude
authored andcommitted
Add catalogue-size cap for PYAUTO_SMALL_DATASETS smoke mode
SMALL_DATASETS_N_CATALOGUE (25) + cap_catalogue_size_for_small_datasets(n) in dataset_util, beside the existing pixel caps: catalogue-shaped datasets (e.g. weak-lensing shear catalogues) have no pixel grid, so entry count is their smoke-mode size lever. Applies to generated sizes only, never user-provided grids/catalogues. Step 9 of the weak-lensing series (PyAutoLabs/PyAutoLens#583). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 27fe67c commit 2bf9ad3

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

autoarray/util/dataset_util.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,25 @@ def should_simulate(dataset_path):
7171
shutil.rmtree(dataset_path)
7272

7373
return not Path(dataset_path).exists()
74+
75+
SMALL_DATASETS_N_CATALOGUE = 25
76+
77+
78+
def cap_catalogue_size_for_small_datasets(n: int) -> int:
79+
"""
80+
Cap a catalogue-style dataset size (e.g. the number of weak-lensing background
81+
galaxies) to the small-datasets limit when ``PYAUTO_SMALL_DATASETS=1`` is active.
82+
83+
Catalogue datasets have no pixel grid, so the (15, 15) array cap above does not
84+
apply to them; the number of catalogue entries is their size lever. Returns ``n``
85+
unchanged when the env var is not set to ``"1"`` or ``n`` is already at-or-below
86+
the cap (25).
87+
88+
Simulators should apply this to *generated* catalogue sizes only (e.g. a
89+
requested number of random positions) — never to a user-provided grid or
90+
catalogue, which must round-trip unmodified.
91+
"""
92+
if os.environ.get("PYAUTO_SMALL_DATASETS") != "1":
93+
return n
94+
95+
return min(n, SMALL_DATASETS_N_CATALOGUE)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from autoarray.util import dataset_util
2+
3+
4+
def test__cap_catalogue_size__inactive_without_env_var(monkeypatch):
5+
monkeypatch.delenv("PYAUTO_SMALL_DATASETS", raising=False)
6+
7+
assert dataset_util.cap_catalogue_size_for_small_datasets(200) == 200
8+
9+
10+
def test__cap_catalogue_size__caps_when_active(monkeypatch):
11+
monkeypatch.setenv("PYAUTO_SMALL_DATASETS", "1")
12+
13+
assert dataset_util.cap_catalogue_size_for_small_datasets(200) == 25
14+
assert dataset_util.cap_catalogue_size_for_small_datasets(10) == 10

0 commit comments

Comments
 (0)