exoplanet-dev / exoplanet-dev/exoplanet

Tutorial Error for Trace Function

Open
#292 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
239
Forks
57
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
A clear and concise description of what the bug is.
In the tutorial whenever I have to use trace. For example, in ‘a quick intro to pymc3’, the code
trace = pm.sample(
draws=1000, tune=1000, chains=2, cores=2, return_inferencedata=True)
Gives an error:
“AttributeError: module 'arviz' has no attribute 'from_pymc3' “

**To Reproduce**
This section should include a simple, standalone code snippet that demonstrates the issue.

!pip install exoplanet
!python -m pip install -U "exoplanet[extras]"
!python -m pip install tensorflow==2.11.1
!python -m pip install tensorflow-datasets==4.9
!python -m pip install tensorflow-metadata==1.13
!python -m pip install protobuf==3.19.6
!python -m pip install pymc==5.1.1
!python -m pip install pymc3==3.11.4
import exoplanet as xo

import pymc3 as pm
import arviz as az

with pm.Model() as model:
m = pm.Uniform("m", lower=-5, upper=5)
b = pm.Uniform("b", lower=-5, upper=5)
logs = pm.Uniform("logs", lower=-5, upper=5)
pm.Normal("obs", mu=m * x + b, sd=pm.math.exp(logs), observed=y)
trace = pm.sample(
draws=1000, tune=1000, chains=2, cores=2, return_inferencedata=True
)

**Expected behavior**
A clear and concise description of what you expected to happen.
It should perform the trace function like in the tutorial.

**Your setup (please complete the following information):**
- Version of exoplanet: 0.5.3
- Operating system: IPad, google collab
- Python version & installation method (pip, conda, etc.): !pip through google collab

**Additional context**
Add any other context about the problem here.

I believe this error is due to an update on pymc3 that “the Latest PyMC3 release (3.11.0) is the first to not include the alias such as pm.traceplot. You have to use [arviz.plot_trace]which works with PyMC3 objects.” OriolAbril from stack overflow.

Additionally, and maybe this is the problem. Due to some dependencies, I had to downgrade certain things in exoplanet to get it to run on google collaborator. The code to get it to run in collab is what I pasted earlier with the code I got the error from:

!pip install exoplanet
!python -m pip install -U "exoplanet[extras]"
!python -m pip install tensorflow==2.11.1
!python -m pip install tensorflow-datasets==4.9
!python -m pip install tensorflow-metadata==1.13
!python -m pip install protobuf==3.19.6
!python -m pip install pymc==5.1.1
!python -m pip install pymc3==3.11.4
import exoplanet as xo

Lastly, I am an undergraduate student, so I apologize if this is an elementary error.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the tutorial setup in the issue, including the pinned PyMC, TensorFlow, and ArviZ-related dependencies, and inspect the versions involved in the missing from_pymc3 attribute. Done means the tutorial's pm.sample call completes without this error under a documented, working dependency combination.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
documentation, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.