From a0a273f4f14bf152a31098b9de5d4e9a6dd3f149 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 7 Apr 2026 10:28:06 +0100 Subject: [PATCH] refactor: re-export test_mode from autoconf instead of defining locally The canonical source is now autoconf.test_mode. This module re-exports for backward compatibility. Also add dependency graph to CLAUDE.md. Co-Authored-By: Claude Opus 4.6 (1M context) --- CLAUDE.md | 45 +++++++++++++++++++-------------- autofit/non_linear/test_mode.py | 21 ++------------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index ee160989b..4114cd7d6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,6 +6,13 @@ - Requires Python >= 3.9 - Package name: `autofit` +## Dependency Graph + +PyAutoFit depends on **autoconf** (shared configuration and utilities). +PyAutoFit does **NOT** depend on PyAutoArray, PyAutoGalaxy, or PyAutoLens. +Never import from `autoarray`, `autogalaxy`, or `autolens` in this repo. +Shared utilities (e.g. `test_mode`, `jax_wrapper`) belong in autoconf. + ## Repository Structure - `autofit/` - Main package @@ -38,25 +45,25 @@ - `anesthetic==2.8.14` - Posterior analysis/plotting - Optional: `nautilus-sampler`, `ultranest`, `zeus-mcmc`, `getdist` -## Running Tests - -``` -pytest test_autofit -pytest test_autofit/non_linear -pytest test_autofit/mapper -``` - -## Codex / sandboxed runs - -When running Python from Codex or any restricted environment, set writable cache directories so `numba` and `matplotlib` do not fail on unwritable home or source-tree paths: - -```bash -NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib pytest test_autofit -``` - -This workspace is often imported from `/mnt/c/...` and Codex may not be able to write to module `__pycache__` directories or `/home/jammy/.cache`, which can cause import-time `numba` caching failures without this override. - -## Shell Commands +## Running Tests + +``` +pytest test_autofit +pytest test_autofit/non_linear +pytest test_autofit/mapper +``` + +## Codex / sandboxed runs + +When running Python from Codex or any restricted environment, set writable cache directories so `numba` and `matplotlib` do not fail on unwritable home or source-tree paths: + +```bash +NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib pytest test_autofit +``` + +This workspace is often imported from `/mnt/c/...` and Codex may not be able to write to module `__pycache__` directories or `/home/jammy/.cache`, which can cause import-time `numba` caching failures without this override. + +## Shell Commands - Prefer simple shell commands - Avoid chaining with `&&` or pipes; run commands separately diff --git a/autofit/non_linear/test_mode.py b/autofit/non_linear/test_mode.py index 537d05a03..e824833b6 100644 --- a/autofit/non_linear/test_mode.py +++ b/autofit/non_linear/test_mode.py @@ -1,20 +1,3 @@ -import os +from autoconf.test_mode import test_mode_level, is_test_mode - -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 +__all__ = ["test_mode_level", "is_test_mode"]