Skip to content
Snippets Groups Projects
Commit 19660ff6 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Elevate the warning message to an error and do the same for emcee

parent 46ddcccb
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ import numpy as np
from pandas import DataFrame
from ..utils import logger, get_progress_bar
from .base_sampler import MCMCSampler
from .base_sampler import MCMCSampler, SamplerError
class Emcee(MCMCSampler):
......@@ -116,6 +116,10 @@ class Emcee(MCMCSampler):
self.calculate_autocorrelation(sampler.chain.reshape((-1, self.ndim)))
self.print_nburn_logging_info()
self.result.nburn = self.nburn
if self.result.nburn > self.nsteps:
raise SamplerError(
"The run has finished, but the chain is not burned in: "
"`nburn < nsteps`. Try increasing the number of steps.")
self.result.samples = sampler.chain[:, self.nburn:, :].reshape((-1, self.ndim))
self.result.walkers = sampler.chain
self.result.log_evidence = np.nan
......
......@@ -2,8 +2,9 @@ from __future__ import absolute_import, division, print_function
import numpy as np
from ..utils import get_progress_bar, logger
from ..utils import get_progress_bar
from . import Emcee
from .base_sampler import SamplerError
class Ptemcee(Emcee):
......@@ -74,7 +75,9 @@ class Ptemcee(Emcee):
self.print_nburn_logging_info()
self.result.nburn = self.nburn
if self.result.nburn > self.nsteps:
logger.warning('Chain not burned in, no samples generated.')
raise SamplerError(
"The run has finished, but the chain is not burned in: "
"`nburn < nsteps`. Try increasing the number of steps.")
self.result.samples = sampler.chain[0, :, self.nburn:, :].reshape(
(-1, self.ndim))
self.result.betas = sampler.betas
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment