Skip to content

fix(tutorials): accept xp kwarg in inline model_data_from#47

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/nautilus-jax-example
Apr 30, 2026
Merged

fix(tutorials): accept xp kwarg in inline model_data_from#47
Jammy2211 merged 1 commit into
mainfrom
feature/nautilus-jax-example

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

  • Adds xp=np to model_data_from on the inline Gaussian and Exponential (overview_1_the_basics.py) and GaussianNoConfig (cookbooks/configs.py) tutorial classes.
  • Routes array math through xp rather than np so the same code paths work under af.ex.Analysis(use_jax=True).
  • Regenerates the corresponding notebooks via PyAutoBuild/generate.py.

Why

PyAutoFit#1240 added xp=self._xp to af.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 bare af.Model(...), but it broke any inline tutorial class whose model_data_from(self, xvalues) did not accept xp:

TypeError: model_data_from() got an unexpected keyword argument 'xp'

Confirmed broken before this PR: scripts/overview/overview_1_the_basics.py (Gaussian) and scripts/cookbooks/configs.py (GaussianNoConfig). Confirmed fixed after this PR.

Exponential is 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 in autofit_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 earlier main commits but were never regenerated. Reverting them would re-introduce script ↔ notebook drift, so they're included.

Related

Test plan

  • PYAUTO_TEST_MODE=1 python3 scripts/overview/overview_1_the_basics.py completes without TypeError
  • PYAUTO_TEST_MODE=1 python3 scripts/cookbooks/configs.py completes
  • python3 scripts/searches/Nautilus_jax.py (autofit_workspace_test) still emits "JAX: Applying vmap and jit to likelihood function" and converges (log_Z ≈ -64.13)
  • CI smoke tests pass

🤖 Generated with Claude Code

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>
@Jammy2211 Jammy2211 merged commit ccec1e2 into main Apr 30, 2026
5 checks passed
@Jammy2211 Jammy2211 deleted the feature/nautilus-jax-example branch April 30, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant