From 8b1d8e293f606dddbcd2faf6a40976cb6b3e12f1 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 7 Apr 2026 10:28:01 +0100 Subject: [PATCH] feat: add test_mode module for shared test mode utilities Move test_mode_level() and is_test_mode() to autoconf so they can be used by any PyAuto library without cross-dependencies. Previously these lived in autofit, but autoarray needed them too and does not depend on autofit. Co-Authored-By: Claude Opus 4.6 (1M context) --- autoconf/__init__.py | 1 + autoconf/test_mode.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 autoconf/test_mode.py diff --git a/autoconf/__init__.py b/autoconf/__init__.py index 3a0de8a..313b4ce 100644 --- a/autoconf/__init__.py +++ b/autoconf/__init__.py @@ -9,6 +9,7 @@ from .json_prior.config import JSONPriorConfig from .setup_colab import for_autolens +from .test_mode import test_mode_level, is_test_mode __version__ = "2026.4.5.3" diff --git a/autoconf/test_mode.py b/autoconf/test_mode.py new file mode 100644 index 0000000..537d05a --- /dev/null +++ b/autoconf/test_mode.py @@ -0,0 +1,20 @@ +import os + + +def test_mode_level(): + """ + Return the current test mode level. + + 0 = off (normal operation) + 1 = reduce sampler iterations to minimum (existing behavior) + 2 = bypass sampler entirely, call likelihood once + 3 = bypass sampler entirely, skip likelihood call + """ + return int(os.environ.get("PYAUTOFIT_TEST_MODE", "0")) + + +def is_test_mode(): + """ + Return True if any test mode is active. + """ + return test_mode_level() > 0