|
| 1 | +# PyAutoLens — Agent Instructions |
| 2 | + |
| 3 | +**PyAutoLens** is a Python library for strong gravitational lens modeling, built on PyAutoGalaxy. It adds multi-plane ray-tracing via the `Tracer` object and lensing-specific fit/analysis classes. |
| 4 | + |
| 5 | +## Setup |
| 6 | + |
| 7 | +```bash |
| 8 | +pip install -e ".[dev]" |
| 9 | +``` |
| 10 | + |
| 11 | +## Running Tests |
| 12 | + |
| 13 | +```bash |
| 14 | +python -m pytest test_autolens/ |
| 15 | +python -m pytest test_autolens/lens/test_tracer.py |
| 16 | +python -m pytest test_autolens/imaging/test_fit_imaging.py -s |
| 17 | +``` |
| 18 | + |
| 19 | +### Sandboxed / Codex runs |
| 20 | + |
| 21 | +```bash |
| 22 | +NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib python -m pytest test_autolens/ |
| 23 | +``` |
| 24 | + |
| 25 | +## Key Architecture |
| 26 | + |
| 27 | +- **Tracer** (`lens/tracer.py`): groups galaxies by redshift plane, performs multi-plane ray-tracing |
| 28 | +- **Fit classes**: `FitImaging`, `FitInterferometer`, `FitPointDataset` — extend autogalaxy equivalents with lensing |
| 29 | +- **Analysis classes**: `AnalysisImaging`, `AnalysisInterferometer`, `AnalysisPoint` |
| 30 | +- **Namespace**: `al.mp.*` (mass), `al.lp.*` (light), `al.Galaxy`, `al.Tracer` |
| 31 | + |
| 32 | +## Dependencies |
| 33 | + |
| 34 | +- `autogalaxy` — galaxy morphology, profiles, single-plane fitting |
| 35 | +- `autoarray` — data structures, grids, masks, inversions |
| 36 | +- `autofit` — non-linear search and model-fitting framework |
| 37 | + |
| 38 | +## Key Rules |
| 39 | + |
| 40 | +- The `xp` parameter controls NumPy vs JAX: `xp=np` (default) or `xp=jnp` |
| 41 | +- Functions inside `jax.jit` must guard autoarray wrapping with `if xp is np:` |
| 42 | +- Decorated functions return **raw arrays** — the decorator wraps them |
| 43 | +- All files must use Unix line endings (LF) |
| 44 | +- Format with `black autolens/` |
| 45 | + |
| 46 | +## Working on Issues |
| 47 | + |
| 48 | +1. Read the issue description and any linked plan. |
| 49 | +2. Identify affected files and write your changes. |
| 50 | +3. Run the full test suite: `python -m pytest test_autolens/` |
| 51 | +4. Ensure all tests pass before opening a PR. |
| 52 | +5. If changing public API, note the change in your PR description — downstream workspaces may need updates. |
0 commit comments