widgetti / ipyvolume

3d plotting for Python in the Jupyter notebook based on IPython widgets using WebGL
MIT License
1.95k stars 236 forks source link

"Error displaying widget" happens #263

Open jehyunlee opened 5 years ago

jehyunlee commented 5 years ago

I have installed ipyvolume and other components for jupyterlab as recommended. There was no error messages and I believe all processes were performed properly, however, I meet Error displaying widget message whenever I try ipyvolulme as shown below screenshot.

screenshot 2019-07-23 15-12-18

For easy comparison with tutorials, I run a few cells and pasted the results below.

MCMC example

https://github.com/maartenbreddels/ipyvolume/blob/master/docs/source/example_mcmc.ipynb

import pylab
import scipy.optimize as op
import emcee
import numpy as np
%matplotlib inline
# our 'blackbox' 3 parameter model which is highly degenerate
def f_model(x, a, b, c):
    return x * np.sqrt(a**2 +b**2 + c**2) + a*x**2 + b*x**3
N = 100
a_true, b_true, c_true = -1., 2., 1.5

# our input and output
x = np.random.rand(N)*0.5#+0.5
y = f_model(x, a_true, b_true, c_true)

# + some (known) gaussian noise
error = 0.2
y += np.random.normal(0, error, N)

# and plot our data
pylab.scatter(x, y);
pylab.xlabel("$x$")
pylab.ylabel("$y$")
Text(0, 0.5, '$y$')

png

# our likelihood
def lnlike(theta, x, y, error):
    a, b, c = theta
    model =  f_model(x, a, b, c)
    chisq = 0.5*(np.sum((y-model)**2/error**2))
    return -chisq
result = op.minimize(lambda *args: -lnlike(*args), [a_true, b_true, c_true], args=(x, y, error))
# find the max likelihood
a_ml, b_ml, c_ml = result["x"]
print("estimates", a_ml, b_ml, c_ml)
print("true values", a_true, b_true, c_true)
result["message"]
estimates 1.2820726223219492 -2.057163544162576 1.1601376256006772e-05
true values -1.0 2.0 1.5

'Optimization terminated successfully.'
# do the mcmc walk
ndim, nwalkers = 3, 100
pos = [result["x"] + np.random.randn(ndim)*0.1 for i in range(nwalkers)]
sampler = emcee.EnsembleSampler(nwalkers, ndim, lnlike, args=(x, y, error))
sampler.run_mcmc(pos, 1500);
samples = sampler.chain[:, 50:, :].reshape((-1, ndim))
# plot the 2d pdfs
import corner
fig = corner.corner(samples, labels=["$a$", "$b$", "$c$"],
                      truths=[a_true, b_true, c_true])

png

import vaex
import scipy.ndimage
import ipyvolume
ds = vaex.from_arrays(a=samples[...,0].copy(), b=samples[...,1].copy(), c=samples[...,2].copy())
# get 2d histogram
v = ds.count(binby=["a", "b", "c"], shape=64)
# smooth it for visual pleasure
v = scipy.ndimage.gaussian_filter(v, 2)
ipyvolume.quickvolshow(v, lighting=True)
/home/jehyun/anaconda3/lib/python3.7/site-packages/ipyvolume/serialize.py:81: RuntimeWarning: invalid value encountered in true_divide
  gradient = gradient / np.sqrt(gradient[0]**2 + gradient[1]**2 + gradient[2]**2)

VBox(children=(VBox(children=(HBox(children=(Label(value='levels:'), FloatSlider(value=0.1, max=1.0, step=0.00…
clu5 commented 5 years ago

I have this same issue in JupyterLab 0.35.4.

kvnsng commented 5 years ago

I'm having a similar issue. I really can't figure out what's wrong. I've installed everything under one of my conda environments, but I can't seem to get ipywidgets working. I'd appreciate any help!

image

maartenbreddels commented 5 years ago

You could try for jupyter lab <1.0 to install an older version of ipyvolume's frontend code:

$ jupyter labextension install ipyvolume@0.5.1

But now that jupyter lab 1.0 is out I'd advise you to use that.

maartenbreddels commented 5 years ago

Please provide a screenshot of the javascript console, or the output of it, so I have more information.