You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Copies and to_dict do not keep per-Q fitted values, and to_dict is not JSON-serializable #293
copy() and from_dict(to_dict()) rebuild a model from its constructor arguments (#126 made that work for every model class). State that is generated per Q after construction is therefore not carried over:
SampleModel, ResolutionModel, BackgroundModel: the per-Q component collections, i.e. the values, bounds and fixed flags fitted at each Q. A copy starts again from the template components.
ResolutionModel: whether it has been calibrated.
InstrumentModel: the per-Q energy offsets.
DeltaLorentz, MittagLefflerDiffusion with allow_Q_variation: the per-Q A_0, width, relaxation rate and alpha lists.
So copying a fitted model, or saving and reloading it, silently loses the fit.
Separately, to_dict() is not JSON-serializable when Q is set (a scipp Variable), nor for an Experiment with data (a DataArray), so a model cannot be written to a file yet.
Things to decide:
Whether a copy should carry the per-Q state or stay a copy of the template (both are useful; the second is what "make a new analysis from this sample model" wants).
How to serialize the per-Q components generated by diffusion models, whose parameters depend on the diffusion model's.
A JSON encoding for Q and for the experiment data.
Activity