rendering delay with interact widgets in ipython notebook

  • Last Update :
  • Techknowledgy :

In action it looks like this:

from ipywidgets
import *
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0, 1, 0.01)
def pltsin(f):
   plt.plot(t, np.sin(2 * np.pi * t * f))
plt.show()
interact(pltsin, f = FloatSlider(min = 1, max = 23, step = 1, continuous_update = False))

Suggestion : 2

Sign up for our newsletter to get our latest blog updates delivered to your inbox weekly.

\
SORRY / \/\
This page does /
] not exist yet.[, '|][/  |] ___ ___[, '   |]]\ / [
   [ |: | ]
]\ / [
   [ |: | ]
]][
   [
      [ |: | ]
   ]
] __ __[[
[ |: | ]
]]]\ _ / [
      [
         [
            [ |: | ]
         ]
      ]
   ](#)[[
      [
         [: === = ']
      ]
   ] _].nHn.[_[[
         []
      ]] HHHHH.[
         [
            []
         ] / `HH("N  \ [  [
           ]__]/     HHH  "  \[__[
           ]         NNN         [
           ]         N/"         [
           ]         N H         [
          /          N            \
         /           q,            \
        /                           \

Suggestion : 3

In particular, the widget javascript not detected error comes from having an old ipywidgets with a new widgetsnbextension package.,I have been experimenting with ipywidgets, and have run into very limited success. At first, I was able to properly run a widget with a single float slider, and it would perform perfectly and update real time. However, after copying the code over to another notebook, the slider disappeared and I only had a single frame/plot. Now even testing the basic code from the tutorial does not display sliders.,When trying to debug this issue, I ran into ‘widget javascript not detected’, ‘jupyter widget could not be displayed because the widget state could not be found’, and now ‘ERROR | No such comm target registered: jupyter.widget.version’. After trial and error experimenting with various versions, I managed to have the sliders in working order again, but the plot would update extremely slowly, and collect a queue of events to process, even for very low computational plots.,I am unsure if I properly installed everything, as I have to pip3 install ipywidgets, otherwise it stats that no module is found for ipywidgets. I am currently on version 7.2.1 for ipywidgets and 3.2.1 for widgetsnbextension.

Does a simple slider work faster?

from ipywidgets
import IntSlider, IntText, link
w = IntSlider()
x = IntText()
link((w, 'value'), (x, 'value'))
display(w)
display(x)

Pip freeze:

backports - abc == 0.5
backports.shutil - get - terminal - size == 1.0 .0
bleach == 2.1 .3
certifi == 2017.7 .27 .1
chardet == 3.0 .4
configparser == 3.5 .0
cycler == 0.10 .0
decorator == 4.3 .0
entrypoints == 0.2 .3
enum34 == 1.1 .6
functools32 == 3.2 .3.post2
futures == 3.2 .0 -
   e git + https: //github.com/openai/gym@797a25d1b1a8823b305fdb575c4378a5c288b432#egg=gym
   html5lib == 1.0 .1
idna == 2.5
ipykernel == 4.8 .2
ipython == 5.7 .0
ipython - genutils == 0.2 .0
ipywidgets == 7.2 .1
Jinja2 == 2.10
jsonschema == 2.6 .0
jupyter - client == 5.2 .3
jupyter - core == 4.4 .0
MarkupSafe == 1.0
matplotlib == 2.0 .2
mercurial == 4.2 .1
mistune == 0.8 .3
nbconvert == 5.3 .1
nbformat == 4.4 .0
notebook == 5.5 .0
numpy == 1.13 .0
pandocfilters == 1.4 .2
pathlib2 == 2.3 .2
pexpect == 4.5 .0
pickleshare == 0.7 .4
pip - autoremove == 0.9 .0
prompt - toolkit == 1.0 .15
ptyprocess == 0.5 .2
pyglet == 1.2 .4
Pygments == 2.2 .0
pyparsing == 2.2 .0
pyportmidi == 0.0 .7
python - dateutil == 2.7 .3
pytz == 2017.2
pyzmq == 17.0 .0
requests == 2.18 .2
scandir == 1.7
scipy == 0.19 .1
Send2Trash == 1.5 .0
simplegeneric == 0.8 .1
singledispatch == 3.4 .0 .3
six == 1.11 .0
subprocess32 == 3.2 .7
terminado == 0.8 .1
testpath == 0.3 .1
tornado == 5.0 .2
traitlets == 4.3 .2
urllib3 == 1.22
wcwidth == 0.1 .7
webencodings == 0.5 .1
widgetsnbextension == 3.2 .1
yasm == 0.0

jupyter nbextension list:

Known nbextensions:
   config dir: /Users/Patrick / .jupyter / nbconfig
notebook section
jupyter - js - widgets / extension enabled -
   Validating: OK
config dir: /usr/local / Cellar / python @2 / 2.7 .15 / Frameworks / Python.framework / Versions / 2.7 / etc / jupyter / nbconfig
notebook section
jupyter - js - widgets / extension enabled -
   Validating: OK
config dir: /usr/local / etc / jupyter / nbconfig
notebook section
jupyter - js - widgets / extension enabled -
   Validating: OK