diff --git a/bilby/core/sampler/emcee.py b/bilby/core/sampler/emcee.py index 932462884755676ff52d721ef458b83f27c6e5cf..cec198d11bbe3933acc878ce585919d6d06846fc 100644 --- a/bilby/core/sampler/emcee.py +++ b/bilby/core/sampler/emcee.py @@ -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 diff --git a/bilby/core/sampler/ptemcee.py b/bilby/core/sampler/ptemcee.py index ca252471061a4ca03d9291e05dd1734f58d56206..ce1fa17b564a64518551a85d7f193d79e27c1db6 100644 --- a/bilby/core/sampler/ptemcee.py +++ b/bilby/core/sampler/ptemcee.py @@ -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