Skip to content

Upgrade examples - #31

Merged
InfinityMonkeyAtWork merged 27 commits into
mainfrom
upgrade-examples
Jul 1, 2026
Merged

Upgrade examples#31
InfinityMonkeyAtWork merged 27 commits into
mainfrom
upgrade-examples

Conversation

@InfinityMonkeyAtWork

Copy link
Copy Markdown
Owner

No description provided.

Example 01 (basic_fitting):
- Regenerate synthetic data over a longer pre-perturbation baseline
  (time -20..100, 481 slices) so GLP.m is well-constrained and can vary
  instead of being fixed; add models_{energy,time}_truth.yaml and a
  generate_data.ipynb that writes the CSVs with a stable %.6e format.
- Update example.ipynb: absolute-time baseline window (-20..-10, clear of
  the IRF-smeared onset), matching fit limits, and explanatory text.

Library:
- Slice-by-slice serial path uses a tqdm progress bar instead of a raw
  carriage-return print, which flooded nbconvert/Jupyter output. Plain
  tqdm (not tqdm.auto) to avoid the ipywidgets dependency.
- fit_slice_by_slice / fit_2d now display the data/fit/residual maps
  inline when show_output>=1 even without auto_export, mirroring
  fit_baseline; CSV/PNG writes stay gated behind auto_export via a new
  save_files flag on the legacy export helpers.
- Standardize results_to_df save_df on the {-2,-1,0,1} finalize-plot
  convention (default -2; 0 now means display-only).

Docs / examples:
- Add example 12_uncertainty_mcmc and wire it into the docs index,
  quickstart, and example READMEs.

Tests:
- Cover the show_output>=1 + auto_export=False display path for
  fit_slice_by_slice and fit_2d (maps shown, no files written).
Move to synthetic data

Do not reject convolution components if the model is a single component model (use case is a global IRF in multi-cycle dynamics models)
Separated data generation into its own notebook similar to the other examples
context manager to correctly spawn parallel processes for both noteboook and standard python callers
- rename fit_wrapper's `sigmas` -> `ci_sigmas`, disambiguating the CI/MCMC
  confidence levels from the data-noise sigma (File.set_sigma / sigma_data)
- make the MCMC noise-scale nuisance parameter configurable via
  MC(sigma_ini/sigma_min/sigma_max) instead of a hardcoded log(0.1)/[0.001,2]
- add MCMCResult (utils/lmfit) and the live File accessors get_correlations /
  get_conf_intervals / get_mcmc (+ _result_model), so callers read fit outputs
  through the public API instead of indexing result[1..4]
- fix fit_wrapper mutating par_fin.params in place: deepcopy before adding
  __lnsigma so the MCMC nuisance parameter no longer leaks into the stored
  leastsq result (result[1]) and its downstream consumers
- tests: MC sigma-knob validation/reach, the __lnsigma-leak regression, and
  the three new accessors
- update docs to clarify 11 and 12 are based on other examples
- consistently use file from archive instead of session file
update quickstart and index docs as well
- output only parameters that are varied
- this aligns with lmfit.conf_interval bahavior (and others)
- rename 20_fit_each_separately -> 20_multi_file_independent_fit
  (clearer; matches the notebook H1). Update all references:
  READMEs, docs/quickstart, docs/examples/index.rst,
  examples_upgrade.md, CHANGELOG, TODO, .gitignore, and the
  notebook-11 cross-link.
- fix systematic baseline bias: the SD~3 IRF onset at t0=0 leaked
  the peak shift back into the baseline window (t<=-4, ~1.3 sigma),
  biasing the static ground-state params in proportion to each
  file's shift amplitude. Pull the window to t<=-8.5 (time_stop
  12 -> 3) so static params recover truth and the residual dipole
  clears (data_1 chi2_red_raw 0.10 -> 0.05).
- correct compare_models prose: the survey is not pre-ranked (sort
  it yourself) and carries no per-parameter columns.
- reword "bridge to 2x" -> "bridge to shared-parameter fitting".
- gitignore the generated batch_export/ export tree.
- rename 21_project_level_shared_fit -> 21_multi_file_shared_fit  (parallel to 20). Update all references
  - extend basline to earlier times and increase noise level similar to example 01 (chi2_red_raw ~1.0 (was an over-polished ~0.05))
- add Section 4 (shared-vs-per-file parameter
  table checked against truth)

Note: regenerating the shared dataset also updates example 20's
notebook (data path, time limits, baseline window) and the 6 CSVs.
test ran skill on existing examples and fixed the issues it surfaced
housekeeping before PR
@InfinityMonkeyAtWork
InfinityMonkeyAtWork merged commit e655091 into main Jul 1, 2026
3 checks passed
@InfinityMonkeyAtWork
InfinityMonkeyAtWork deleted the upgrade-examples branch July 1, 2026 23:58
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