PyAutoFit is a Python probabilistic programming language for model fitting and Bayesian inference.
- Authors: James Nightingale, Richard Hayes
- Requires Python >= 3.12
- Package name:
autofit
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.
autofit/- Main packagenon_linear/- Non-linear search algorithmssearch/mcmc/- MCMC (emcee, zeus)search/mle/- Maximum likelihood (LBFGS, BFGS, drawer)search/nest/- Nested sampling (dynesty, nautilus)samples/- Posterior samples handlingpaths/- Output path managementanalysis/- Analysis base classes
mapper/- Model and prior machineryprior/- Prior distributionsprior_model/- Prior model compositionmodel.py- Core model class
graphical/- Graphical models and expectation propagationaggregator/- Results aggregation across runsdatabase/- SQLAlchemy-based results databaseinterpolator/- Model interpolationconfig/- Default config files packaged with library
test_autofit/- Test suite (pytest)docs/- Sphinx documentation
dynesty==2.1.5- Nested samplingemcee>=3.1.6- MCMCscipy<=1.14.0- OptimisationSQLAlchemy==2.0.32- Database backendanesthetic==2.8.14- Posterior analysis/plotting- Optional:
nautilus-sampler,zeus-mcmc,getdist
pytest test_autofit
pytest test_autofit/non_linear
pytest test_autofit/mapper
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:
NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib pytest test_autofitThis 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.
- Prefer simple shell commands
- Avoid chaining with
&&or pipes; run commands separately
- autofit_workspace (tutorials/examples):
../autofit_workspace
NEVER perform these operations on any repo with a remote:
git initin a directory already tracked by gitrm -rf .git && git init- Commit with subject "Initial commit", "Fresh start", "Start fresh", "Reset for AI workflow", or any equivalent message on a branch with a remote
git push --forcetomain(or any branch tracked asorigin/HEAD)git filter-repo/git filter-branchon shared branchesgit rebase -irewriting commits already pushed to a shared branch
If the working tree needs a clean state, the only correct sequence is:
git fetch origin
git reset --hard origin/main
git clean -fd
This applies equally to humans, local Claude Code, cloud Claude agents, Codex, and any other agent. The "Initial commit — fresh start for AI workflow" pattern that appeared independently on origin and local for three workspace repos is exactly what this rule prevents — it costs ~40 commits of redundant local work every time it happens.