Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
1a02090
Split persistence ADR and add fit output ADR
AndrewSazonov May 18, 2026
394158b
Add artifact root for reproducible tutorials
AndrewSazonov May 18, 2026
c40b015
Finalize Project facade decision
AndrewSazonov May 18, 2026
e2d64b7
Store auto rendering defaults in project config
AndrewSazonov May 18, 2026
1dabc44
Accept loop category key identity ADR
AndrewSazonov May 18, 2026
68a8057
Add project save to ed-2 tutorial
AndrewSazonov May 18, 2026
d039633
Remove extraneous blank line
AndrewSazonov May 18, 2026
d5770f0
Add project fit verbosity category
AndrewSazonov May 18, 2026
c2d36f0
Add analysis fit state implementation plan
AndrewSazonov May 18, 2026
527e018
Reformat documentation tables and line breaks
AndrewSazonov May 18, 2026
daa31f1
Add project fit verbosity verification
AndrewSazonov May 18, 2026
fa1fac4
Clarify analysis fit-state ADR schema
AndrewSazonov May 18, 2026
703a387
Add common analysis fit-state categories
AndrewSazonov May 18, 2026
6368687
Add deterministic fit-result categories
AndrewSazonov May 18, 2026
4b656b8
Add Bayesian fit-result metadata categories
AndrewSazonov May 18, 2026
b28197c
Add Bayesian fit-cache manifest categories
AndrewSazonov May 18, 2026
5c8a251
Add project save step to tutorial
AndrewSazonov May 18, 2026
643061d
Wire analysis fit-state CIF restore
AndrewSazonov May 18, 2026
723e260
Linting and formatting
AndrewSazonov May 18, 2026
c27e389
Add h5py dependency
AndrewSazonov May 18, 2026
407389b
Capture persisted fit-state projections
AndrewSazonov May 18, 2026
386ccec
Persist Bayesian fit arrays in results sidecar
AndrewSazonov May 18, 2026
7cf25bd
Restore fit results from saved analysis state
AndrewSazonov May 18, 2026
0de17d4
Align persisted fit-state schema with review feedback
AndrewSazonov May 18, 2026
6020753
Persist Bayesian plot caches in sidecar
AndrewSazonov May 18, 2026
09186c1
Add integer type and skip redundant processing
AndrewSazonov May 18, 2026
9cef32a
Update tutorial notebooks with consistent IDs and saves
AndrewSazonov May 18, 2026
6fda12f
Add pre/post-processing tracking to Bayesian fits
AndrewSazonov May 18, 2026
9a13a28
Add project-first CLI commands for saved projects
AndrewSazonov May 18, 2026
970ef96
Fix missing pre-processing row in DREAM progress table
AndrewSazonov May 18, 2026
3b59134
Add CLI commands for example data downloads
AndrewSazonov May 18, 2026
b99a719
Remove pattern display from tutorial
AndrewSazonov May 18, 2026
72a0f9e
Group saved-project tutorials under Load Project
AndrewSazonov May 18, 2026
fec75c2
Consolidate download and extract in tutorials
AndrewSazonov May 18, 2026
ef953f6
Refactor Bayesian fit-state manifest create APIs
AndrewSazonov May 18, 2026
9d0542c
Remove deterministic parameter-result persistence
AndrewSazonov May 18, 2026
6e741ff
Update data index reference and hash
AndrewSazonov May 18, 2026
4814a59
Consolidate saved project tutorials to download_data
AndrewSazonov May 18, 2026
dfe3f6c
Remove deterministic_parameter_results from docs
AndrewSazonov May 18, 2026
d988410
Revise docs for CLI syntax and project loading
AndrewSazonov May 18, 2026
18a69f2
Update undo command to show it's a placeholder
AndrewSazonov May 18, 2026
c117a55
Harden fit-state sidecar paths and finalize ADR
AndrewSazonov May 18, 2026
0ae7d57
Reorder CLI command definitions
AndrewSazonov May 18, 2026
9671b86
Restore saved DREAM sampler settings on project load
AndrewSazonov May 18, 2026
d1c7f97
Restore legacy DREAM sampler settings before CLI fit
AndrewSazonov May 18, 2026
bbd4bd6
Clarify DREAM multiprocessing issue for direct scripts
AndrewSazonov May 18, 2026
e37e2de
Update data index ref and hash
AndrewSazonov May 18, 2026
4b4826d
Add DREAM multiprocessing issue #95
AndrewSazonov May 18, 2026
265752e
Remove obsolete package references from docs
AndrewSazonov May 18, 2026
ba32f26
Update CIF serializer test for long descriptions
AndrewSazonov May 18, 2026
8176617
Update ADR suggestions for implemented fit-state work
AndrewSazonov May 19, 2026
e828edc
Accept parameter correlation persistence ADR
AndrewSazonov May 19, 2026
a850eea
Rename sequential fit result CSV columns
AndrewSazonov May 19, 2026
a573b6b
Add overwrite option to Project.save_as
AndrewSazonov May 19, 2026
2f12067
Improve code formatting and docstrings
AndrewSazonov May 19, 2026
de92f6e
Update data index reference and hash
AndrewSazonov May 19, 2026
33456bf
Simplify tutorial with API shortcuts
AndrewSazonov May 19, 2026
4dc0a1b
Improve tutorial index descriptions
AndrewSazonov May 19, 2026
e796e6e
Accept str or list for column_names
AndrewSazonov May 19, 2026
7b078fd
Fix fit tracking finalization cleanup
AndrewSazonov May 19, 2026
37fc390
Add tutorial benchmark runner and pixi task
AndrewSazonov May 19, 2026
a7b7016
Write benchmark results incrementally
AndrewSazonov May 19, 2026
d2d35c4
Reduce tutorial computation time and fix data ID
AndrewSazonov May 19, 2026
d809c04
Simplify tutorial titles for consistency
AndrewSazonov May 19, 2026
b8c9122
Honor max_iterations in BUMPS fits
AndrewSazonov May 19, 2026
60359ac
Add tutorial benchmark results
AndrewSazonov May 19, 2026
cec16f6
Refactor BumpsMinimizer evaluation limit handling
AndrewSazonov May 19, 2026
10f206c
Plot fit quality vs temperature
AndrewSazonov May 19, 2026
e7247b3
Improve output formatting and add logging
AndrewSazonov May 19, 2026
f220fcb
Optimize tutorial execution time
AndrewSazonov May 19, 2026
dda5c94
Add newline before saved path
AndrewSazonov May 19, 2026
208a3e7
Remove notebook timeout, add CI artifact root
AndrewSazonov May 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ Notes:
`docs/dev/package-structure/short.md` automatically — never edit those
by hand. Don't review auto-fixes; accept and move on. Then
`pixi run check` until clean.
- When a check command needs saved output for analysis, capture the log
and preserve the command exit code with a zsh-safe variable name:
`pixi run check > /tmp/easydiffraction-check.log 2>&1; check_exit_code=$?; tail -n 200 /tmp/easydiffraction-check.log; exit $check_exit_code`.
Never assign to `status` in zsh; it is readonly. Use task-specific
names such as `check_exit_code`, `unit_tests_exit_code`, or
`script_tests_exit_code`.
- Open issues / design questions / planned improvements live in
`docs/dev/issues/open.md` (priority-ordered). On resolution, move to
`docs/dev/issues/closed.md` and update the relevant ADR or
Expand Down Expand Up @@ -204,6 +210,9 @@ When asked to create a plan:
files likely to change, decisions already made, open questions,
verification commands for Phase 2, and a short suggested commit
message or branch name when useful.
- Verification commands in plans must include the zsh-safe log-capture
pattern from **Workflow** whenever saved output is needed for later
analysis.
- Before saving a plan, verify that referenced files, directories,
scripts, and task names exist locally when that is practical. If a
referenced tool is optional or missing, include an available fallback.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
# Uses multiple cores for parallel execution to speed up the process.
- name: Run notebooks
# if: false # Temporarily disabled to speed up the docs build
run: pixi run notebook-exec
run: pixi run notebook-exec-ci

# Build the static files for the documentation site for local inspection
# Input: docs/ directory containing the Markdown files
Expand Down
193 changes: 193 additions & 0 deletions docs/dev/adrs/accepted/analysis-cif-fit-state.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# ADR: Analysis CIF Fit State

## Status

Accepted current design.

## Date

2026-05-18

## Group

Analysis and fitting.

## Context

`analysis/analysis.cif` already persists analysis configuration such as
`_fitting.minimizer_type`, `_fitting.mode_type`, aliases, constraints,
and active fit-mode settings. That configuration alone is not enough to
reopen a saved project and continue the same fit-result, plotting, and
command-line workflow.

Analysis-owned fit state needs to persist:

- fit bounds and bound provenance
- pre-fit scalar snapshots for recovery workflows
- compact status metadata for the latest saved fit projection
- deterministic correlation summaries
- Bayesian summary metadata and manifests for bulk array sidecars
- plot-ready Bayesian caches so restored posterior displays do not need
to recompute on first use

Committed model parameter values and uncertainties already persist in
structure and experiment CIF files through the accepted free-flag CIF
encoding. Those committed values must remain the source of truth for the
current model state.

The accepted runtime fit-results ADR keeps backend runtime objects
runtime-only unless a narrower persistence ADR defines a saved
projection. This ADR defines that narrower saved projection.

## Decision

Persist analysis-owned fit state as explicit sibling categories in
`analysis/analysis.cif`, with large Bayesian arrays stored in
`analysis/results.h5`.

Do not add a dedicated `_fit_state` category or
`_fit_state.schema_version`. Persisted fit state is detected from
`_fit_result` and the related fit-state categories.

### Common fit-state categories

Persist these common categories for any saved fit projection:

- `_fit_parameter`
- `_fit_result`
- `_fit_parameter_correlation`

`_fit_parameter` stores analysis-owned per-parameter fit controls and
pre-fit scalar snapshots:

- `param_unique_name`
- `fit_min`
- `fit_max`
- `fit_bounds_uncertainty_multiplier`
- `start_value`
- `start_uncertainty`

`_fit_result` stores the latest saved fit header:

- `result_kind`
- `success`
- `message`
- `iterations`
- `fitting_time`
- `reduced_chi_square`

`_fit_parameter_correlation` stores pairwise deterministic or posterior
correlation summaries keyed by a persisted `id`. Only unique parameter
pairs are stored.

### Deterministic fit projection

Deterministic fits persist `_deterministic_result` in addition to the
common categories above.

`_deterministic_result` stores compact optimizer metadata and counts:

- `optimizer_name`
- `method_name`
- `objective_name`
- `objective_value`
- `n_data_points`
- `n_parameters`
- `n_free_parameters`
- `degrees_of_freedom`
- `covariance_available`
- `correlation_available`

Do not persist a `_deterministic_parameter_result` category. Final
deterministic parameter values and uncertainties already persist in the
model CIF files, and restored deterministic ordering comes from
`_fit_parameter`.

### Bayesian fit projection

Bayesian fits persist these additional categories:

- `_bayesian_result`
- `_bayesian_sampler`
- `_bayesian_convergence`
- `_bayesian_parameter_posterior`
- `_bayesian_distribution_cache`
- `_bayesian_pair_cache`
- `_bayesian_predictive_dataset`

`_bayesian_result` stores the saved Bayesian header and sidecar flags,
including `sidecar_file`, `has_posterior_samples`,
`has_distribution_cache`, `has_pair_cache`, and
`has_posterior_predictive`.

`_bayesian_sampler` stores the resolved sampler settings used for the
run. `parallel` persists the resolved non-negative worker count as an
integer.

`_bayesian_convergence` stores convergence metadata and posterior array
shape counts.

`_bayesian_parameter_posterior` stores one summary row per sampled
parameter, including credible intervals, uncertainty, ESS, and R-hat.
Its row order defines the saved posterior parameter order.

`_bayesian_distribution_cache`, `_bayesian_pair_cache`, and
`_bayesian_predictive_dataset` store manifest rows for plot-ready
posterior caches. Distribution and predictive caches are persisted for
any Bayesian fit with posterior samples, including single-parameter
fits. Pair caches and posterior correlation summaries are only persisted
when more than one parameter was sampled.

`parameter.posterior` is not part of this accepted design. This ADR
persists analysis-level posterior summaries and caches only. Any future
parameter-level posterior API remains a separate decision.

### Bayesian sidecar

Persist large Bayesian arrays in `analysis/results.h5` using `h5py`.
This includes canonical posterior arrays and any saved distribution,
pair, and predictive cache arrays referenced by the CIF manifests.

The persisted `sidecar_file` value is a local file name only. It must
resolve to a basename inside the project `analysis/` directory. Absolute
paths and traversal paths are rejected and fall back to `results.h5`.

If the sidecar is missing on load, summary rows in
`analysis/analysis.cif` still restore fit tables and metadata. Features
that require missing bulk arrays must warn clearly instead of failing
silently.

### Save and restore behavior

After a fit completes, project save writes the fit-state projection
before the project is considered fully persisted. For Bayesian fits,
that includes the prepared summaries and saved plot caches used by
posterior displays.

Load order is:

1. standard analysis configuration
2. common fit-state categories
3. deterministic or Bayesian fit-specific categories according to
`_fit_result.result_kind`
4. Bayesian sidecar arrays when a Bayesian sidecar is expected

Persist backend runtime objects, optimizer instances, and raw driver
payloads nowhere in this design.

## Consequences

Saved projects reopen with enough fit-state context to display the last
saved result and rerun fits without rebuilding analysis-owned bounds by
hand.

Deterministic persistence stays compact because committed parameter
values remain in the model CIF files instead of being duplicated in a
second deterministic per-parameter result loop.

Bayesian persistence spans CIF metadata and an HDF5 sidecar, so save and
load must validate consistency between manifest rows and bulk datasets.

The accepted runtime fit-results ADR should now be read as runtime-only
except where this narrower projection explicitly persists fit-state
metadata, summaries, and cache arrays.
Loading
Loading