diff --git a/bilby/core/sampler/emcee.py b/bilby/core/sampler/emcee.py index 75eaed43da6405808142277a8a4f952029a23d9c..b74314e000e248b28eee3f69f2372fc648c45359 100644 --- a/bilby/core/sampler/emcee.py +++ b/bilby/core/sampler/emcee.py @@ -38,7 +38,7 @@ class Emcee(MCMCSampler): """ default_kwargs = dict(nwalkers=500, a=2, args=[], kwargs={}, - postargs=None, threads=1, pool=None, live_dangerously=False, + postargs=None, pool=None, live_dangerously=False, runtime_sortingfn=None, lnprob0=None, rstate0=None, blobs0=None, iterations=100, thin=1, storechain=True, mh_proposal=None) @@ -62,6 +62,14 @@ class Emcee(MCMCSampler): if 'iterations' not in kwargs: if 'nsteps' in kwargs: kwargs['iterations'] = kwargs.pop('nsteps') + if 'threads' in kwargs: + if kwargs['threads'] != 1: + logger.warning("The 'threads' argument cannot be used for " + "parallelisation. This run will proceed " + "without parallelisation, but consider the use " + "of an appropriate Pool object passed to the " + "'pool' keyword.") + kwargs['threads'] = 1 @property def sampler_function_kwargs(self): diff --git a/test/sampler_test.py b/test/sampler_test.py index cd40784c786189ae8dd640889c9330b8b0ef4dac..0ffbb2bac84f0096fa8dc7e20052b0ad1ee09b78 100644 --- a/test/sampler_test.py +++ b/test/sampler_test.py @@ -191,7 +191,7 @@ class TestEmcee(unittest.TestCase): def test_default_kwargs(self): expected = dict(nwalkers=500, a=2, args=[], kwargs={}, - postargs=None, threads=1, pool=None, live_dangerously=False, + postargs=None, pool=None, live_dangerously=False, runtime_sortingfn=None, lnprob0=None, rstate0=None, blobs0=None, iterations=100, thin=1, storechain=True, mh_proposal=None ) @@ -199,7 +199,7 @@ class TestEmcee(unittest.TestCase): def test_translate_kwargs(self): expected = dict(nwalkers=100, a=2, args=[], kwargs={}, - postargs=None, threads=1, pool=None, live_dangerously=False, + postargs=None, pool=None, live_dangerously=False, runtime_sortingfn=None, lnprob0=None, rstate0=None, blobs0=None, iterations=100, thin=1, storechain=True, mh_proposal=None) for equiv in bilby.core.sampler.base_sampler.MCMCSampler.nwalkers_equiv_kwargs: