emcee: ValueError: algorithm must be 'MT19937' when creating sampler
General information:
- emcee version: v3.0rc2
- platform: Ubuntu 18.04.1 LTS
- installation method (pip/conda/source/other?): pip install emcee==3.0rc2
Problem description:
Running emcee.EnsembleSampler() throws error.
Expected behavior:
No error, creating the sampler correctly.
Actual behavior:
ValueError: algorithm must be 'MT19937'
What have you tried so far?:
The error is coming from emcee/ensemble.py, line 133. I tried printing state variable, and it seems like the first element of this list, which should be 'MT19937' is in reality b'MT19937'. So it seems like it is a bytes string. As a quick fix I tried setting state[0] = 'MT19937' just before the call to set_state and it seems to work fine, although this solution is obviously no good.
Minimal example:
import emcee
# File with posterior class:
import posterior as pos
posterior = pos.posterior()
filename = 'test.chains'
name = '000'
ndim = 3
nwalkers = 10
max_n = 10000
backend = emcee.backends.HDFBackend(filename, name=name)
sampler = emcee.EnsembleSampler(nwalkers, ndim, log_prob_fn=posterior.lnpos,
args=[[ns_range[0], ns_range[1]],[]], backend=backend)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (9 by maintainers)
I am seeing the same error, and the fix proposed above works for me as well (thanks @iipr for posting!).
emcee: 3.0.0, installed via conda python: 3.7.3 platform: Scientific Linux 7.7
Interesting. Thanks for reporting this. This definitely isn’t the expected behavior. I’ll look into this. What version of Python are you on, just so I know?