fix(tutorials): accept xp kwarg in inline model_data_from#47
Merged
Conversation
PyAutoFit#1240 added `xp=self._xp` to the bare-Model branch of `af.ex.Analysis.model_data_1d_from`. Inline tutorial classes that defined `model_data_from(self, xvalues)` without the `xp` parameter broke with `TypeError: unexpected keyword argument 'xp'` whenever the script reached `af.ex.Analysis(...).fit(...)`. Update Gaussian and Exponential in overview_1_the_basics.py and GaussianNoConfig in cookbooks/configs.py to accept `xp=np` and route their array math through `xp` rather than `np`. Other methods (`__call__`, `inverse`, `f`, `fwhm`) are not reached from `af.ex.Analysis` and remain unchanged. Notebooks regenerated via PyAutoBuild/generate.py. Two unrelated notebook diffs are included where the .ipynb had drifted from script edits that landed on main (graphical_models, overview_3_statistical_methods URL updates). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
xp=nptomodel_data_fromon the inlineGaussianandExponential(overview_1_the_basics.py) andGaussianNoConfig(cookbooks/configs.py) tutorial classes.xprather thannpso the same code paths work underaf.ex.Analysis(use_jax=True).Why
PyAutoFit#1240 added
xp=self._xptoaf.ex.Analysis.model_data_1d_from's bare-Model branch (it was already passed in the Collection branch). That fixed a latent bug where JAX-jitted likelihoods couldn't run on a bareaf.Model(...), but it broke any inline tutorial class whosemodel_data_from(self, xvalues)did not acceptxp:Confirmed broken before this PR:
scripts/overview/overview_1_the_basics.py(Gaussian) andscripts/cookbooks/configs.py(GaussianNoConfig). Confirmed fixed after this PR.Exponentialis updated for consistency even though it currently rides a Collection branch with a custom Analysis in the script — the user-chosen scope for this PR is "all inline classes inautofit_workspace".Notebook diff scope
The PR also includes two unrelated notebook diffs (
notebooks/features/graphical_models.ipynb,notebooks/overview/overview_3_statistical_methods.ipynb) — these caught up to script-side URL edits that landed in earliermaincommits but were never regenerated. Reverting them would re-introduce script ↔ notebook drift, so they're included.Related
xpparity for 7 dev scripts)Test plan
PYAUTO_TEST_MODE=1 python3 scripts/overview/overview_1_the_basics.pycompletes withoutTypeErrorPYAUTO_TEST_MODE=1 python3 scripts/cookbooks/configs.pycompletespython3 scripts/searches/Nautilus_jax.py(autofit_workspace_test) still emits "JAX: Applying vmap and jit to likelihood function" and converges (log_Z ≈ -64.13)🤖 Generated with Claude Code