Repository navigation
Description
Overview
af.ex.Analysis.log_likelihood_function (autofit/example/analysis.py:148) reduces the chi-squared map with the Python builtin sum(chi_squared_map). Under JAX this only works by iterating the traced array element by element, and it is the wrong pattern for the example analysis that tutorials and workspace scripts copy from. Replace it with self._xp.sum(...).
Plan
- Swap the builtin
sumforself._xp.sumin the example Analysis log likelihood (matches theself._xppattern already used inmodel_data_1d_from). - Leave the unused
xp=npparameter untouched (signature change is out of scope). - Verify with the existing example-Analysis tests under both NumPy and JAX.
Tier: glance — merge mode: auto-merge on green if the Witness passes, post-merge summary
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| PyAutoFit | main | clean |
PyAutoFit is also claimed by three-autos-public-framing (docs) and ep-projected-model-shared-prior (samples.py + tests); human-approved conflict override 2026-11-15 — non-overlapping file, separate branch off main.
Suggested branch: feature/example-analysis-xp-sum
Implementation Steps
autofit/example/analysis.py:log_likelihood = -0.5 * self._xp.sum(chi_squared_map).- Witness: grep shows
self._xp.sum(and no baresum(inlog_likelihood_function. - Run
pytest test_autofitincluding the JAX users ofaf.ex.Analysis:non_linear/test_fitness_assertions_jax.py,non_linear/search/mle/test_bfgs_jax_gradient.py,graphical/test_shared_state.py,non_linear/test_fitness_objective.py.
Key Files
autofit/example/analysis.py— example Analysis log likelihood
Original Prompt
Click to expand starting prompt
Example Analysis should reduce with xp.sum not builtin sum
Type: refactor
Target: PyAutoFit
Repos:
- PyAutoFit
Difficulty: small
Autonomy: safe
Priority: normal
Status: formalised
Consequence: glance
Witness: autofit/example/analysis.py log_likelihood_function contains self._xp.sum( and no bare sum( call; the example test suite passes under both NumPy and JAX.
Review-minutes: 3
Unattended: ready
Lane: any
af.ex.Analysis.log_likelihood_function (autofit/example/analysis.py:147) reduces the chi-squared map with the Python builtin sum(chi_squared_map) instead of self._xp.sum. It works under JAX only by iterating the traced array element by element, and it is the wrong pattern for the example analysis that tutorials and workspace scripts copy from. Replace it with self._xp.sum(...). Found 2026-09-10.
Activity
Jammy2211 commentedon Nov 15, 2026
Shipped
af.ex.Analysis.log_likelihood_functionnow reduces the chi-squared map withself._xp.sum(...)instead of the builtinsum.self._xp.sum(present, no baresum(in the method.test_autofitlocally (Python 3.13, jax 0.12,.[optional]): 4288 passed / 2 skipped / 1 xfailed. CI: unittest 3.12, 3.13, nojax, docs-build, generated-search-docs all green.pending-releaseuntil the next PyAutoFit release.git revert -m 1 5f580d5Generated by Claude Code