exoplanet-dev / exoplanet

Fast & scalable MCMC for all your exoplanet needs!
https://docs.exoplanet.codes
MIT License
206 stars 52 forks source link

LimbDark object can't be pickled, stops sampling in the transit example #124

Closed aditya-sengupta closed 3 years ago

aditya-sengupta commented 3 years ago

Describe the bug When trying to run exoplanet/docs/tutorials/transit.py, execution is stopped at the sampling stage on line 155: the stated error is TypeError: cannot pickle 'exoplanet.theano_ops.driver.LimbDark' object.

To Reproduce cd into docs/tutorials and run python transit.py: output is reproduced below.

optimizing logp for variables: [b, r, u, logP, t0, mean]
106it [00:01, 82.32it/s, logp=2.479354e+04]
message: Desired error not necessarily achieved due to precision loss.
logp: 24787.977771807487 -> 24793.53942561123
Auto-assigning NUTS sampler...
Initializing NUTS using adapt_full...
/Users/adityasengupta/opt/anaconda3/envs/oracle/lib/python3.8/site-packages/pymc3/step_methods/hmc/quadpotential.py:503: UserWarning: QuadPotentialFullAdapt is an experimental feature
  warnings.warn("QuadPotentialFullAdapt is an experimental feature")
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [b, r, u, logP, t0, mean]
Traceback (most recent call last):
  File "transit.py", line 149, in <module>
    trace = pm.sample(
  File "/Users/adityasengupta/opt/anaconda3/envs/oracle/lib/python3.8/site-packages/pymc3/sampling.py", line 545, in sample
    trace = _mp_sample(**sample_args, **parallel_args)
  File "/Users/adityasengupta/opt/anaconda3/envs/oracle/lib/python3.8/site-packages/pymc3/sampling.py", line 1470, in _mp_sample
    sampler = ps.ParallelSampler(
  File "/Users/adityasengupta/opt/anaconda3/envs/oracle/lib/python3.8/site-packages/pymc3/parallel_sampling.py", line 432, in __init__
    step_method_pickled = pickle.dumps(step_method, protocol=-1)
TypeError: cannot pickle 'exoplanet.theano_ops.driver.LimbDark' object

Expected behavior The same output as in the docs at https://docs.exoplanet.codes/en/stable/tutorials/transit/.

Your setup (please complete the following information):

Additional context Add any other context about the problem here.

dfm commented 3 years ago

Thanks!

This is a duplicate of #115 and it was fixed in #120. This will be included in the next release if you don't want to build from source.

LucieScharre commented 3 years ago

Hello, I'm a student trying to use this package for a project. I have not used github before and am experiencing the same issue! I have tried to implement the fix #120, but am just getting new error messages. Should the approach work of just replacing exoplanet directory (installed using pip) with the new version I've downloaded from here?

I'm getting this error message then: ImportError: cannot import name 'driver' from 'exoplanet.theano_ops' (/Applications/anaconda3/lib/python3.7/site-packages/exoplanet/theano_ops/init.py)

I'm not the most experienced coder and don't know to what extent I should mess around with the source code.

aditya-sengupta commented 3 years ago

Looks like it's still running the pip installed version; try the following (in some directory you want to use for this)

git clone https://github.com/exoplanet-dev/exoplanet
cd exoplanet
git submodule update --init --recursive
python setup.py develop
dfm commented 3 years ago

I'll also plan on making a pip release early next week so that it'll be easier to use then. Thanks for your patience!!

LucieScharre commented 3 years ago

That would be great as I still can't get it to work, just getting new error messages... Thank both of you so much!

LucieScharre commented 3 years ago

Are there any obvious fixes for [Errno 32] Broken pipe?

aditya-sengupta commented 3 years ago

Have pm.sample use only one core

On Sat, Nov 14, 2020 at 4:48 AM LucieScharre notifications@github.com wrote:

Are there any obvious fixes for [Errno 32] Broken pipe?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/exoplanet-dev/exoplanet/issues/124#issuecomment-727202698, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIK476Q4AJF4NTYGTUZCZS3SPZ4A7ANCNFSM4TRIGJTA .

dfm commented 3 years ago

The package on PyPI has been updated so you should be able to get the new version using

python -m pip install -U exoplanet

For other errors (like a broken pipe) can you open a new issue with an example that demonstrates the problem? Then it'll be easier for me to look into it!

LucieScharre commented 3 years ago

It now works with the new version! Thank you for fixing it so quickly!

LucieScharre commented 3 years ago

Do you by any chance have examples of how to fit just one planet to the data? No worries if not! Just struggling a little with a working translation to only one planet

dfm commented 3 years ago

Take a look at the examples on the case studies page to see if those are enough to get you started: https://gallery.exoplanet.codes/en/latest/