|
| 1 | +# PyAutoFit |
| 2 | + |
| 3 | +**PyAutoFit** is a Python probabilistic programming language for model fitting and Bayesian inference. |
| 4 | + |
| 5 | +- Authors: James Nightingale, Richard Hayes |
| 6 | +- Requires Python >= 3.9 |
| 7 | +- Package name: `autofit` |
| 8 | + |
| 9 | +## Repository Structure |
| 10 | + |
| 11 | +- `autofit/` - Main package |
| 12 | + - `non_linear/` - Non-linear search algorithms |
| 13 | + - `search/mcmc/` - MCMC (emcee, zeus) |
| 14 | + - `search/mle/` - Maximum likelihood (LBFGS, pyswarms) |
| 15 | + - `search/nest/` - Nested sampling (dynesty, nautilus, ultranest) |
| 16 | + - `samples/` - Posterior samples handling |
| 17 | + - `paths/` - Output path management |
| 18 | + - `analysis/` - Analysis base classes |
| 19 | + - `mapper/` - Model and prior machinery |
| 20 | + - `prior/` - Prior distributions |
| 21 | + - `prior_model/` - Prior model composition |
| 22 | + - `model.py` - Core model class |
| 23 | + - `graphical/` - Graphical models and expectation propagation |
| 24 | + - `aggregator/` - Results aggregation across runs |
| 25 | + - `database/` - SQLAlchemy-based results database |
| 26 | + - `interpolator/` - Model interpolation |
| 27 | + - `config/` - Default config files packaged with library |
| 28 | +- `test_autofit/` - Test suite (pytest) |
| 29 | +- `docs/` - Sphinx documentation |
| 30 | + |
| 31 | +## Key Dependencies |
| 32 | + |
| 33 | +- `dynesty==2.1.4` - Nested sampling |
| 34 | +- `emcee>=3.1.6` - MCMC |
| 35 | +- `pyswarms==1.3.0` - Particle swarm optimisation |
| 36 | +- `scipy<=1.14.0` - Optimisation |
| 37 | +- `SQLAlchemy==2.0.32` - Database backend |
| 38 | +- `anesthetic==2.8.14` - Posterior analysis/plotting |
| 39 | +- Optional: `nautilus-sampler`, `ultranest`, `zeus-mcmc`, `getdist` |
| 40 | + |
| 41 | +## Running Tests |
| 42 | + |
| 43 | +``` |
| 44 | +pytest test_autofit |
| 45 | +pytest test_autofit/non_linear |
| 46 | +pytest test_autofit/mapper |
| 47 | +``` |
| 48 | + |
| 49 | +## Codex / sandboxed runs |
| 50 | + |
| 51 | +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: |
| 52 | + |
| 53 | +```bash |
| 54 | +NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib pytest test_autofit |
| 55 | +``` |
| 56 | + |
| 57 | +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. |
| 58 | + |
| 59 | +## Shell Commands |
| 60 | + |
| 61 | +- Prefer simple shell commands |
| 62 | +- Avoid chaining with `&&` or pipes; run commands separately |
| 63 | + |
| 64 | +## Related Repos |
| 65 | + |
| 66 | +- **autofit_workspace** (tutorials/examples): `../autofit_workspace` |
0 commit comments