Skip to content

Commit 6a4887e

Browse files
Refactor fit modes and sequential analysis workflow (#175)
* Rename Bayesian MAP labels to best posterior sample * Add ADR for fit mode categories * Refine fit-mode categories ADR with active-sibling pattern * Add open questions and drop fitting.mode mirror in ADR * Add implementation plan for fit-mode-categories ADR * Rename CIF field _fitting.mode to _fitting.mode_type * Tighten high-risk steps in fit-mode-categories plan * Add BoolDescriptor for CIF-bound boolean values * Add fitting category replacing fit configuration surface * Add fitting_mode_type selector and fitting accessor on Analysis * Rename joint_fit_experiments category to joint_fit * Add sequential_fit category with persisted scan settings * Add sequential_fit_extract category for scan metadata rules * Replace fit category with Analysis.fit() method * Drive sequential fitting from sequential_fit settings * Auto-populate joint_fit rows and validate before fitting * Add instance-aware help filter and hide inactive mode categories * Serialize only active mode-specific analysis categories * Restore mode before mode-specific analysis sections * Update tutorials, docs, and exports for new fitting API * Resolve ZIP extraction relative to saved project * Add live progress tables for sequential fitting * Set sequential fitting mode and save project * Complete fit-mode categories and refactor progress * Fix sequential replay, styling, and docs * Simplify sequential progress table headers * Add progress and time columns to sequential tables * Unify sequential and single fit spinners on ActivityIndicator * Fix spacing in chunk file range display * Render sequential progress as bordered table with index column * Render sequential progress with shared single-fit table renderable * Add fit.series_all to plot every fitted parameter * Unify fit.series to plot single or all fitted parameters * Encapsulate chunk progress in dataclass * Use string paths for versus parameter * Unify ASCII plot width handling across terminal charts * Sort ASCII parameter series by x before plotting * Skip fit reports for sequential mode * List all analysis files on save * Bump dependencies * Add resumed sequential-fit tutorial for Co2SiO4 * Update data index reference and hash * Clear sequential fit state and make ZIP extraction explicit * Update data index reference and hash * Normalize sequential CSV paths for resumed fits * Update data index reference and hash * Add resume fit tutorial and fix paths * Normalize CSV relative paths to POSIX style * Remove project save step from tutorial * Accept fit-mode categories ADR * Move Quick Reference to end of nav * Lower coverage threshold to 65%
1 parent 1a94b59 commit 6a4887e

115 files changed

Lines changed: 5770 additions & 1850 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/dev/ADR-suggestions/adr_parameter-posterior-summary.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ model.
5454
### 2. Reuse the existing Bayesian summary container
5555

5656
Do not add separate flat parameter attributes such as `median`,
57-
`map_estimate`, `interval_95`, `r_hat`, or `ess_bulk`.
57+
`best_sample_value`, `interval_95`, `r_hat`, or `ess_bulk`.
5858

5959
Instead, the parameter-level projection reuses the existing
6060
`PosteriorParameterSummary` object already produced for
@@ -63,7 +63,7 @@ inspection, and later persistence.
6363

6464
The summary object currently provides the right level of detail:
6565

66-
- `map_estimate`
66+
- `best_sample_value`
6767
- `median`
6868
- `uncertainty`
6969
- `interval_68`
@@ -87,7 +87,7 @@ The internal field names stay compact and code-oriented. User-facing
8787
tables, summaries, and plot annotations should use these friendly
8888
labels:
8989

90-
- `map_estimate` -> `MAP estimate`
90+
- `best_sample_value` -> `Best posterior sample`
9191
- `median` -> `Median`
9292
- `uncertainty` -> `Standard uncertainty`
9393
- `interval_68` -> `68% credible interval`
@@ -109,7 +109,7 @@ current_value = param.value
109109
current_uncertainty = param.uncertainty
110110

111111
if param.posterior is not None:
112-
map_estimate = param.posterior.map_estimate
112+
best_sample_value = param.posterior.best_sample_value
113113
median = param.posterior.median
114114
uncertainty = param.posterior.uncertainty
115115
low95, high95 = param.posterior.interval_95
@@ -187,15 +187,15 @@ The exact helper names can be refined during implementation, but the
187187
design requirement is fixed: manual user edits clear stale metadata,
188188
while internal fit application installs fresh metadata atomically.
189189

190-
### 8. Commit MAP to `parameter.value` after Bayesian fits
190+
### 8. Commit best posterior sample to `parameter.value` after Bayesian fits
191191

192192
After a posterior-capable fit, `parameter.value` is committed from the
193-
maximum-a-posteriori estimate.
193+
best posterior sample.
194194

195-
MAP is chosen because it is a coherent joint point estimate across all
196-
free parameters. Marginal medians remain available on
197-
`parameter.posterior`, but they are summary data rather than the active
198-
live model state.
195+
The best posterior sample is chosen because it is a coherent joint point
196+
estimate across all free parameters. Marginal medians remain available
197+
on `parameter.posterior`, but they are summary data rather than the
198+
active live model state.
199199

200200
### 9. Keep `uncertainty` as a convenience scalar after Bayesian fits
201201

@@ -279,7 +279,7 @@ Stores one saved Bayesian result header with these fields:
279279
- `has_posterior_predictive`
280280
- `sidecar_file`
281281

282-
For the current design, `point_estimate_name` is always `map`.
282+
For the current design, `point_estimate_name` is always `best_sample`.
283283

284284
#### 11.3 `_bayesian_sampler` single item
285285

@@ -320,7 +320,7 @@ Fields:
320320
- `order_index`
321321
- `unique_name`
322322
- `display_name`
323-
- `map_estimate`
323+
- `best_sample_value`
324324
- `median`
325325
- `uncertainty`
326326
- `interval_68_lower`
@@ -342,7 +342,7 @@ Fields:
342342
- `experiment_name`
343343
- `x_axis_name`
344344
- `x_path`
345-
- `map_prediction_path`
345+
- `best_sample_prediction_path`
346346
- `lower_95_path`
347347
- `upper_95_path`
348348
- `lower_68_path`
@@ -382,7 +382,7 @@ cosio.atom_site.Co2.adp_iso 0.0000 0.1200 4.0 0.0312 0.0021
382382
383383
_bayesian_result.schema_version 1
384384
_bayesian_result.sampler_name dream
385-
_bayesian_result.point_estimate_name map
385+
_bayesian_result.point_estimate_name best_sample
386386
_bayesian_result.success yes
387387
_bayesian_result.sampler_completed yes
388388
_bayesian_result.reduced_chi_square 1.031
@@ -413,7 +413,7 @@ loop_
413413
_bayesian_parameter_posterior.order_index
414414
_bayesian_parameter_posterior.unique_name
415415
_bayesian_parameter_posterior.display_name
416-
_bayesian_parameter_posterior.map_estimate
416+
_bayesian_parameter_posterior.best_sample_value
417417
_bayesian_parameter_posterior.median
418418
_bayesian_parameter_posterior.uncertainty
419419
_bayesian_parameter_posterior.interval_68_lower
@@ -429,15 +429,15 @@ loop_
429429
_bayesian_predictive_dataset.experiment_name
430430
_bayesian_predictive_dataset.x_axis_name
431431
_bayesian_predictive_dataset.x_path
432-
_bayesian_predictive_dataset.map_prediction_path
432+
_bayesian_predictive_dataset.best_sample_prediction_path
433433
_bayesian_predictive_dataset.lower_95_path
434434
_bayesian_predictive_dataset.upper_95_path
435435
_bayesian_predictive_dataset.lower_68_path
436436
_bayesian_predictive_dataset.upper_68_path
437437
_bayesian_predictive_dataset.draws_path
438438
_bayesian_predictive_dataset.n_x
439439
_bayesian_predictive_dataset.n_draws_cached
440-
hrpt ttheta /predictive/hrpt/x /predictive/hrpt/map_prediction /predictive/hrpt/lower_95 /predictive/hrpt/upper_95 /predictive/hrpt/lower_68 /predictive/hrpt/upper_68 /predictive/hrpt/draws 2500 200
440+
hrpt ttheta /predictive/hrpt/x /predictive/hrpt/best_sample_prediction /predictive/hrpt/lower_95 /predictive/hrpt/upper_95 /predictive/hrpt/lower_68 /predictive/hrpt/upper_68 /predictive/hrpt/draws 2500 200
441441
```
442442

443443
### 12. Persist bulk arrays in `analysis/bayesian_data.h5`
@@ -482,7 +482,7 @@ ordering.
482482
Recommended HDF5 dataset naming is:
483483

484484
- `predictive__<experiment>__x`
485-
- `predictive__<experiment>__map_prediction`
485+
- `predictive__<experiment>__best_sample_prediction`
486486
- `predictive__<experiment>__lower_95`
487487
- `predictive__<experiment>__upper_95`
488488
- `predictive__<experiment>__lower_68`
@@ -497,7 +497,7 @@ Recommended HDF5 group layout is:
497497
- `/posterior/log_posterior`
498498
- `/posterior/draw_index`
499499
- `/predictive/<experiment>/x`
500-
- `/predictive/<experiment>/map_prediction`
500+
- `/predictive/<experiment>/best_sample_prediction`
501501
- `/predictive/<experiment>/lower_95`
502502
- `/predictive/<experiment>/upper_95`
503503
- `/predictive/<experiment>/lower_68`
@@ -573,7 +573,7 @@ param = project.phases['lbco'].cell.length_a
573573
posterior = param.posterior
574574

575575
if posterior is not None:
576-
print(posterior.map_estimate)
576+
print(posterior.best_sample_value)
577577
print(posterior.uncertainty)
578578
print(posterior.interval_68)
579579

@@ -673,7 +673,8 @@ It still defers:
673673

674674
## Chosen Defaults
675675

676-
- `parameter.value` remains committed to MAP after posterior fits.
676+
- `parameter.value` remains committed to the best posterior sample after
677+
posterior fits.
677678
- If a project is loaded without full posterior arrays, restoring only
678679
`parameter.posterior` is acceptable for table display and parameter
679680
inspection.

docs/dev/ADRs/adr_display-ux.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ project.display.parameters.cif_uids()
7777

7878
project.display.fit.results()
7979
project.display.fit.correlations()
80-
project.display.fit.series(param, versus=temperature)
80+
project.display.fit.series(param, versus='diffrn.ambient_temperature')
8181

8282
project.display.posterior.pairs()
8383
project.display.posterior.distribution(param)
@@ -197,7 +197,8 @@ Use these naming rules:
197197
- `fit.correlations()` shows parameter relationships from the latest
198198
fit.
199199
- `fit.series(param, versus=...)` shows fitted parameter values across a
200-
sequence of fit results or experiments.
200+
sequence of fit results or experiments, using a persisted `diffrn.*`
201+
path for `versus`.
201202
- `posterior.*` names are used only when posterior samples are required.
202203

203204
## Rejected Alternatives
@@ -209,7 +210,7 @@ project.display.pattern(expt_name='hrpt')
209210
project.display.parameters(scope='free')
210211
project.display.fit_results()
211212
project.display.correlations()
212-
project.display.parameter_series(param, versus=temperature)
213+
project.display.parameter_series(param, versus='diffrn.ambient_temperature')
213214
project.display.posterior_pairs()
214215
project.display.posterior_distribution(param)
215216
project.display.posterior_predictive(expt_name='hrpt')

0 commit comments

Comments
 (0)