dfm/emcee

Issue on page /tutorials/quickstart.html

haricash opened this issue · 3 comments

In the line sampler.run_mcmc(state, 10000), the state is a tuple, whose 1st element contains the required initial parameters for the run_mcmc to function. Being a first time user, I ran into this issue because of my naivety. It would be great if the documentation could be changed so that first time users can seamlessly work through the quick start section.

dfm commented

I'm not sure I understand your issue here, that tutorial is an ipynb that is executed from top to bottom - so it definitely runs! What was the missing piece for you?

Sorry, it did work in ipynb! I was running it on python from terminal, and got the following error :

/PATH/TO/lib/python3.9/site-packages/emcee/ensemble.py:190: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. p = np.array(p0) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/PATH/TO/lib/python3.9/site-packages/emcee/sampler.py", line 171, in run_mcmc for results in self.sample(pos0, lnprob0, rstate0, iterations=N, File "/PATH/TO/lib/python3.9/site-packages/emcee/ensemble.py", line 198, in sample lnprob, blobs = self._get_lnprob(p) File "/PATH/TO/lib/python3.9/site-packages/emcee/ensemble.py", line 364, in _get_lnprob if np.any(np.isinf(p)): TypeError: ufunc 'isinf' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

I then only passed the information about the location of each walker for the parameters to the run_mcmc function, which then worked. At that time, I thought this was an error in the documentation. It did not strike me then that I had to run it as an ipynb. I hurriedly opened an issue.

It was much later, when I tried it out in an iPython notebook that I realised my mistake. I then closed the issue.

I apologize for my carelessness.

P.S. Why does this happen? I am quite new to ipynb, and have no idea how things work below the hood.

dfm commented

No problem - it's not that it needs to be run in a notebook. I was just saying that if you run the code in the order that it's listed, it will work, in a notebook or otherwise! I expect that you're either missing a step somewhere when running from the command line, or perhaps you have a version mismatch (line 190 of ensemble.py in the most recent version of emcee, would not throw that error...).