Skip to content

docs: simplify weak/fit.py to load dataset via al.from_json - #212

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/weak-dataset-from-json
May 28, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/weak-dataset-from-json

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

With PyAutoArray #342 fixing the VectorYX2DIrregular round-trip, al.from_json can now load a serialised WeakDataset directly. This PR drops the inline truth_lens / truth_tracer / SimulatorShearYX / via_tracer_random_positions_from reconstruction block from scripts/weak/fit.py (a workaround that existed only because the loader was broken) and replaces it with the natural one-line al.from_json load used by every other tutorial in the workspace.

dataset/weak/simple/dataset.json is regenerated so it carries the new values field — the previously-written file is unreadable by the fixed loader. tracer.json is regenerated alongside (incidental cosmology field + dict-key ordering drift; numeric values identical).

End-to-end verified locally: scripts/weak/simulator.py writes the new dataset.json; scripts/weak/fit.py then loads it cleanly via al.from_json and the fit runs (n_galaxies=200, chi_squared=437.510, log_likelihood=-104.741).

Scripts Changed

  • scripts/weak/fit.py — replaced inline WeakDataset reconstruction with al.from_json(file_path=dataset_path / "dataset.json"); revised the __Dataset__ docstring accordingly. (−20 / +5 lines.)

Dataset Changes

  • dataset/weak/simple/dataset.json — regenerated to carry the values field required by the fixed loader.
  • dataset/weak/simple/tracer.json — regenerated alongside (cosmology field + dict-key ordering refresh; numeric values unchanged).

Upstream PRs

Closes #554.

Test Plan

  • python scripts/weak/simulator.py regenerates dataset.json / tracer.json cleanly
  • python scripts/weak/fit.py loads via al.from_json and runs end-to-end
  • /smoke_test passes for autolens_workspace

🤖 Generated with Claude Code

The original fit.py rebuilt the WeakDataset inline (truth_lens, truth_tracer,
SimulatorShearYX, via_tracer_random_positions_from) because al.from_json on
the simulator-written dataset.json crashed with "VectorYX2DIrregular missing
'values'". The library fix (PyAutoArray #342) added the missing values
property on VectorYX2DIrregular, so dataset.json now round-trips cleanly.

This change drops 20+ lines of inline reconstruction from scripts/weak/fit.py
and restores the natural "simulate -> save -> load -> fit" pattern used by
every other tutorial in the workspace.

dataset/weak/simple/dataset.json is regenerated so it carries the new
`values` field (the previously-written file is unreadable by the fixed
loader). dataset/weak/simple/tracer.json is regenerated alongside
(incidental cosmology field + dict-key ordering refresh; values identical).

Refs PyAutoLens issue #554. Pairs with PyAutoArray #342 and PyAutoLens #555.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 28, 2026
@Jammy2211
Jammy2211 merged commit b037862 into main May 28, 2026
6 checks passed
@Jammy2211
Jammy2211 deleted the feature/weak-dataset-from-json branch May 28, 2026 11:01
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 7, 2026
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