Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot_trace hangs when var_names is omitted #1187

Closed
murphyk opened this issue May 15, 2020 · 2 comments
Closed

plot_trace hangs when var_names is omitted #1187

murphyk opened this issue May 15, 2020 · 2 comments

Comments

@murphyk
Copy link

murphyk commented May 15, 2020

Describe the bug
A clear and concise description of what the bug is.

az.plot_trace(trace) hangs unless var_names is specified

Output:

 az.plot_trace(trace)
/Users/kpmurphy/anaconda3/lib/python3.7/site-packages/arviz/plots/traceplot.py:218: UserWarning: rcParams['plot.max_subplots'] (40) is smaller than the number of variables to plot (102), generating only 40 plots
  UserWarning,
Out[7]: 
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x1a31f5b510>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x1a31fa46d0>],
...

To Reproduce

import pymc3 as pm
import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
import arviz as az

    
np.random.seed(1)
N = 100
alpha_real = 2.5
beta_real = 0.9
noiseSD = 0.5
eps_real = np.random.normal(0, noiseSD, size=N)

x = np.random.normal(10, 1, N) # centered on 10
y_real = alpha_real + beta_real * x
y = y_real + eps_real

with pm.Model() as model:
    w0 = pm.Normal('w0', mu=0, sd=10)
    w1 = pm.Normal('w1', mu=0, sd=1)
    mu = pm.Deterministic('mu', w0 + w1 * x)
    y_pred = pm.Normal('y_pred', mu=mu, sd=noiseSD, observed=y)
    trace = pm.sample(1000)

az.plot_trace(trace, var_names=['w0', 'w1']) # works

az.plot_trace(trace) # hangs

Expected behavior

Should plot trace of w0 and w1

Additional context

az.version '0.7.0'

pm.version '3.8'

@ColCarroll
Copy link
Member

Hey Kevin --
The default changed to draw different variable dimensions in their own axes, so mu is a 100 dimensional variable, and the kernel likely freezes trying to create a large enough plot.

The next release (coming soon!) will bravely fail and give a useful warning about this. To get the previous behavior, use compact=True:
image

@OriolAbril
Copy link
Member

There was a bug in enforcing the rcParam plot.max_subplots, instead of generating 40 plots at max, it allowed up to 80 plots, which is generally too high to prevent freezing (which is the reason to be of this rcParam). This has been fixed in #1205 so I'll close the issue.

If the issue persists, an arvizrc file can be used to modify the default for plot.max_subplots to a more restrictive value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants