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

DOC add example for unimport #269

Closed
MarcoGorelli opened this issue Sep 26, 2020 · 4 comments
Closed

DOC add example for unimport #269

MarcoGorelli opened this issue Sep 26, 2020 · 4 comments

Comments

@MarcoGorelli
Copy link
Collaborator

No description provided.

@MarcoGorelli
Copy link
Collaborator Author

MarcoGorelli commented Sep 27, 2020

this failed when I tried using on PyMC3's notebooks, need to figure out why

it seems to turn

# %%
fig, ax = plt.subplots(2, 2, figsize=(12, 12))
ax = ax.flatten()
contour_pot(pot1f, ax[0], 'pot1', );
contour_pot(pot2f, ax[1], 'pot2');
contour_pot(pot3f, ax[2], 'pot3');
contour_pot(pot4f, ax[3], 'pot4');
fig.tight_layout()

# %%
from pymc3.distributions.dist_math import bound


def cust_logp(z):
    #return bound(-pot1(z), z>-5, z<5)
    return -pot1(z)

with pm.Model() as pot1m:
    pm.DensityDist('pot1', logp=cust_logp, shape=(2,))

# %%
pm.set_tt_rng(42)
np.random.seed(42)
with pot1m:
    trace = pm.sample(1000, init='auto', cores=2, start=[dict(pot1=np.array([-2, 0])),
                                                         dict(pot1=np.array([2, 0]))])

# %%

into

# %%
fig, ax = plt.subplots(2, 2, figsize=(12, 12))
ax = ax.flatten()
contour_pot(pot1f, ax[0], 'pot1', );
contour_pot(pot2f, ax[1], 'pot2');
contour_pot(pot3f, ax[2], 'pot3');
contour_pot(pot4f, ax[3], 'pot4');
fig.tight_layout()


def cust_logp(z):
    #return bound(-pot1(z), z>-5, z<5)
    return -pot1(z)

with pm.Model() as pot1m:
    pm.DensityDist('pot1', logp=cust_logp, shape=(2,))

# %%
pm.set_tt_rng(42)
np.random.seed(42)
with pot1m:
    trace = pm.sample(1000, init='auto', cores=2, start=[dict(pot1=np.array([-2, 0])),
                                                         dict(pot1=np.array([2, 0]))])

# %%

@MarcoGorelli
Copy link
Collaborator Author

MarcoGorelli commented Sep 27, 2020

I don't think there's much we can do about a tool which removes # %% lines, as otherwise we have no way of separating cells. We could/should, though, raise a helpful error message if we fail to reconstruct the notebook


the error message should also redirect users to this GitHub page and encourage them to file a bug report

@MarcoGorelli
Copy link
Collaborator Author

reported here hakancelikdev/unimport#134

@MarcoGorelli
Copy link
Collaborator Author

closing for now as they need to fix their bug first

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

No branches or pull requests

1 participant