Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 12 additions & 11 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ classifiers = [
]
requires-python = '>=3.11'
dependencies = [
'easyscience @ git+https://github.com/easyscience/corelib.git@develop',
# 'easyscience @ git+https://github.com/easyscience/corelib.git@develop',
'easyscience @ git+https://github.com/easyscience/corelib.git@bayesian_extend',
# 'easyscience',
'scipp',
'refnx',
Expand Down
5 changes: 3 additions & 2 deletions src/easyreflectometry/analysis/bayesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,8 +1332,9 @@ def load_posterior(path: str, skip: int = 0) -> 'PosteriorResults':
"""Reload a trace saved by :func:`save_posterior` into a
:class:`PosteriorResults`.

The returned object's ``sampler_state`` can be fed back into
``MultiFitter.mcmc_sample(..., resume_state=...)`` to extend the chain.
The returned object's ``sampler_state`` can be fed back into the core
``Sampler`` (via ``Sampler.load_state(...)`` / ``Sampler.extend(...)``)
to extend the chain.

:param path: File path prefix used in :func:`save_posterior`.
:type path: str
Expand Down
19 changes: 17 additions & 2 deletions src/easyreflectometry/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import scipp as sc
from easyscience.fitting import AvailableMinimizers
from easyscience.fitting import FitResults
from easyscience.fitting import Sampler

Check warning on line 13 in src/easyreflectometry/fitting.py

View check run for this annotation

Codecov / codecov/patch

src/easyreflectometry/fitting.py#L13

Added line #L13 was not covered by tests
from easyscience.fitting.multi_fitter import MultiFitter as EasyScienceMultiFitter

from easyreflectometry.data import DataSet1D
Expand Down Expand Up @@ -419,14 +420,22 @@
y.append(y_eff)
dy.append(weights)

# Delegate the actual BUMPS/DREAM sampling to the core MultiFitter
# Delegate the actual BUMPS/DREAM sampling to the core ``Sampler``.
# The core API moved from ``MultiFitter.mcmc_sample()`` to a dedicated
# ``Sampler`` class: construct it with the configured fitter and the
# bound data, then call ``sample()``. ``Sampler`` handles the
# multi-dataset reshaping internally.
sampler_kwargs = {}
if initializer is not None:
sampler_kwargs['init'] = initializer
return self.easy_science_multi_fitter.mcmc_sample(

sampler = Sampler(

Check warning on line 432 in src/easyreflectometry/fitting.py

View check run for this annotation

Codecov / codecov/patch

src/easyreflectometry/fitting.py#L432

Added line #L432 was not covered by tests
self.easy_science_multi_fitter,
x=x,
y=y,
weights=dy,
)
results = sampler.sample(

Check warning on line 438 in src/easyreflectometry/fitting.py

View check run for this annotation

Codecov / codecov/patch

src/easyreflectometry/fitting.py#L438

Added line #L438 was not covered by tests
samples=samples,
burn=burn,
thin=thin,
Expand All @@ -435,6 +444,12 @@
progress_callback=progress_callback,
abort_test=abort_test,
)
return {

Check warning on line 447 in src/easyreflectometry/fitting.py

View check run for this annotation

Codecov / codecov/patch

src/easyreflectometry/fitting.py#L447

Added line #L447 was not covered by tests
'draws': results.draws,
'param_names': results.param_names,
'state': results.state,
'logp': results.logp,
}

@property
def chi2(self) -> float | None:
Expand Down
Loading
Loading