Repository navigation
refactor: example Analysis reduces chi-squared with xp.sum - #1775
Merged
Merged
Conversation
af.ex.Analysis.log_likelihood_function summed the chi-squared map with the Python builtin sum(), which under JAX iterates the traced array element by element. Use self._xp.sum() so the example tutorials copy from shows the array-API pattern. Closes #1774 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016nhQ8M5qwndUL85fDcyjxG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
af.ex.Analysis.log_likelihood_functionsummed the chi-squared map with the Python builtinsum(), which under JAX iterates the traced array element by element. It now usesself._xp.sum(chi_squared_map), matching theself._xppattern already used inmodel_data_1d_from, so the example analysis that tutorials and workspace scripts copy from shows the right pattern.Closes #1774
API Changes
None — internal implementation change only; return value is numerically identical under NumPy and JAX.
See full details below.
Test Plan
log_likelihood_functioncontainsself._xp.sum(and no baresum(callaf.ex.Analysis(test_fitness_assertions_jax.py,test_bfgs_jax_gradient.py,graphical/test_shared_state.py,test_fitness_objective.py): 58 passedpytest test_autofit(Python 3.13, jax 0.12,.[optional]installed): 4288 passed, 2 skipped, 1 xfailedHeart (published board, dev gate): YELLOW — only blocker "PyAutoArray: open PR 12d old"; no red main CI on PyAutoFit or dependants.
Full API Changes (for automation & release notes)
Changed
autofit.example.analysis.Analysis.log_likelihood_function— reduces withself._xp.suminstead of builtinsum(no signature or behaviour change).Generated by the PyAutoLabs agent workflow.
Generated by Claude Code