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

Merge branch 'raise-error-when-no-samples-produced' into 'master'

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

See merge request !325
parents 46ddcccb 19660ff6
No related branches found
No related tags found
1 merge request!325Elevate the warning message to an error and do the same for emcee
Pipeline #45582 passed with warnings
......@@ -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