From 0dcdce8ab476dcd49e2f5ce99714e3535748a080 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 20:31:47 +0000 Subject: [PATCH] refactor: example Analysis reduces chi-squared with xp.sum 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 Claude-Session: https://claude.ai/code/session_016nhQ8M5qwndUL85fDcyjxG --- autofit/example/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autofit/example/analysis.py b/autofit/example/analysis.py index a71478e61..d699f707c 100644 --- a/autofit/example/analysis.py +++ b/autofit/example/analysis.py @@ -145,7 +145,7 @@ def log_likelihood_function( residual_map = self.data - model_data_1d chi_squared_map = (residual_map / self.noise_map) ** 2.0 - log_likelihood = -0.5 * sum(chi_squared_map) + log_likelihood = -0.5 * self._xp.sum(chi_squared_map) return log_likelihood