{"action":"created","issue":{"url":"https://api.github.com/repos/ioam/holoviews/issues/2799","repository_url":"https://api.github.com/repos/ioam/holoviews","labels_url":"https://api.github.com/repos/ioam/holoviews/issues/2799/labels{/name}","comments_url":"https://api.github.com/repos/ioam/holoviews/issues/2799/comments","events_url":"https://api.github.com/repos/ioam/holoviews/issues/2799/events","html_url":"https://github.com/ioam/holoviews/issues/2799","id":331922418,"node_id":"MDU6SXNzdWUzMzE5MjI0MTg=","number":2799,"title":"Cannot display DynamicMap inside a JupyterLab notebook","user":{"login":"MikulasZelinka","id":13113894,"node_id":"MDQ6VXNlcjEzMTEzODk0","avatar_url":"https://avatars3.githubusercontent.com/u/13113894?v=4","gravatar_id":"","url":"https://api.github.com/users/MikulasZelinka","html_url":"https://github.com/MikulasZelinka","followers_url":"https://api.github.com/users/MikulasZelinka/followers","following_url":"https://api.github.com/users/MikulasZelinka/following{/other_user}","gists_url":"https://api.github.com/users/MikulasZelinka/gists{/gist_id}","starred_url":"https://api.github.com/users/MikulasZelinka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikulasZelinka/subscriptions","organizations_url":"https://api.github.com/users/MikulasZelinka/orgs","repos_url":"https://api.github.com/users/MikulasZelinka/repos","events_url":"https://api.github.com/users/MikulasZelinka/events{/privacy}","received_events_url":"https://api.github.com/users/MikulasZelinka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-13T09:53:15Z","updated_at":"2018-06-13T10:42:05Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\nI can't seem to figure out how to run the [Game of Life](http://holoviews.org/gallery/apps/bokeh/game_of_life.html) example inside a notebook in JupyterLab `0.32.1` with holoviews `1.10.4`, bokeh `0.12.15`.\r\n\r\nThe JupyterLab is running on `localhost:8888`.\r\n\r\nFirst cell \r\n\r\n```python\r\nimport numpy as np\r\nimport holoviews as hv\r\n\r\nfrom holoviews.streams import Tap, Counter\r\nfrom scipy.signal import convolve2d\r\n\r\nrenderer = hv.renderer('bokeh')\r\n\r\ndiehard = [[0, 0, 0, 0, 0, 0, 1, 0],\r\n           [1, 1, 0, 0, 0, 0, 0, 0],\r\n           [0, 1, 0, 0, 0, 1, 1, 1]]\r\n\r\nboat = [[1, 1, 0],\r\n        [1, 0, 1],\r\n        [0, 1, 0]]\r\n\r\nr_pentomino = [[0, 1, 1],\r\n               [1, 1, 0],\r\n               [0, 1, 0]]\r\n\r\nbeacon = [[0, 0, 1, 1],\r\n          [0, 0, 1, 1],\r\n          [1, 1, 0, 0],\r\n          [1, 1, 0, 0]]\r\n\r\nacorn = [[0, 1, 0, 0, 0, 0, 0],\r\n         [0, 0, 0, 1, 0, 0, 0],\r\n         [1, 1, 0, 0, 1, 1, 1]]\r\n\r\nspaceship = [[0, 0, 1, 1, 0],\r\n             [1, 1, 0, 1, 1],\r\n             [1, 1, 1, 1, 0],\r\n             [0, 1, 1, 0, 0]]\r\n\r\nblock_switch_engine = [[0, 0, 0, 0, 0, 0, 1, 0],\r\n                       [0, 0, 0, 0, 1, 0, 1, 1],\r\n                       [0, 0, 0, 0, 1, 0, 1, 0],\r\n                       [0, 0, 0, 0, 1, 0, 0, 0],\r\n                       [0, 0, 1, 0, 0, 0, 0, 0],\r\n                       [1, 0, 1, 0, 0, 0, 0, 0]]\r\n\r\nglider = [[1, 0, 0], [0, 1, 1], [1, 1, 0]]\r\n\r\nunbounded = [[1, 1, 1, 0, 1],\r\n            [1, 0, 0, 0, 0],\r\n            [0, 0, 0, 1, 1],\r\n            [0, 1, 1, 0, 1],\r\n            [1, 0, 1, 0, 1]]\r\n\r\nshapes = {'Glider': glider, 'Block Switch Engine': block_switch_engine,\r\n          'Spaceship': spaceship, 'Acorn': acorn, 'Beacon': beacon,\r\n          'Diehard': diehard, 'Unbounded': unbounded}\r\n\r\ndef step(X):\r\n    nbrs_count = convolve2d(X, np.ones((3, 3)), mode='same', boundary='wrap') - X\r\n    return (nbrs_count == 3) | (X & (nbrs_count == 2))\r\n\r\ndef update(pattern, counter, x, y):\r\n    if counter:\r\n        img.data = step(img.data)\r\n    if x and y:\r\n        pattern = np.array(shapes[pattern])\r\n        r, c = pattern.shape\r\n        y, x = img.sheet2matrixidx(x,y)\r\n        img.data[y:y+r,x:x+c] = pattern[::-1]\r\n    return hv.Image(img)\r\n\r\ntitle = 'Game of Life - Tap to place pattern, Doubletap to clear'\r\nopts =  {\r\n    'style': {'cmap': 'gray', 'toolbar': False, },\r\n    'plot' : {'height': 400, 'width': 800, 'title_format': '{label}',\r\n              'xaxis': None, 'yaxis': None}\r\n}\r\nimg = hv.Image(np.zeros((100, 200), dtype=np.uint8))\r\ncounter, tap = Counter(transient=True), Tap(transient=True)\r\npattern_dim = hv.Dimension('Pattern', values=sorted(shapes.keys()))\r\ndmap = hv.DynamicMap(update, kdims=[pattern_dim], streams=[counter, tap])\r\n\r\n# doc = renderer.server_doc(dmap.redim.range(z=(0, 1)).opts(**opts))\r\n# doc.title = 'Game of Life'\r\n\r\napp = renderer.app(dmap.redim.range(z=(0, 1)).opts(**opts), show=True, websocket_origin='localhost:8888')\r\n```\r\n\r\ngives:\r\n`INFO:bokeh.server.server:Starting Bokeh server version 0.12.15 (running on Tornado 5.0.2)`\r\n\r\nSecond cell:\r\n```python\r\ndmap.periodic(0.05)\r\n```\r\n\r\ngives no output -- it keeps running and upon interruption, it is clear that it can't connect:\r\n```python\r\nKeyboardInterrupt                         Traceback (most recent call last)\r\n<ipython-input-3-8f5136ab6c88> in <module>()\r\n----> 1 dmap.periodic(0.05)\r\n\r\n.../python3.6/site-packages/holoviews/core/spaces.py in __call__(self, period, count, param_fn, timeout, block)\r\n    692         instance = self._periodic_util(period, count, inner,\r\n    693                                        timeout=timeout, block=block)\r\n--> 694         instance.start()\r\n    695         self.instance= instance\r\n    696 \r\n\r\n.../python3.6/site-packages/holoviews/core/util.py in start(self)\r\n    174             super(periodic,self).start()\r\n    175         else:\r\n--> 176             self.run()\r\n    177 \r\n    178     def stop(self):\r\n.../python3.6/site-packages/holoviews/core/util.py in run(self)\r\n    190         while not self.completed:\r\n    191             if self.block:\r\n--> 192                 time.sleep(self.period)\r\n    193             else:\r\n    194                 self._completed.wait(self.period)\r\n\r\nKeyboardInterrupt:\r\n```\r\n\r\nAny help would be greatly appreciated :)"},"comment":{"url":"https://api.github.com/repos/ioam/holoviews/issues/comments/396894170","html_url":"https://github.com/ioam/holoviews/issues/2799#issuecomment-396894170","issue_url":"https://api.github.com/repos/ioam/holoviews/issues/2799","id":396894170,"node_id":"MDEyOklzc3VlQ29tbWVudDM5Njg5NDE3MA==","user":{"login":"MikulasZelinka","id":13113894,"node_id":"MDQ6VXNlcjEzMTEzODk0","avatar_url":"https://avatars3.githubusercontent.com/u/13113894?v=4","gravatar_id":"","url":"https://api.github.com/users/MikulasZelinka","html_url":"https://github.com/MikulasZelinka","followers_url":"https://api.github.com/users/MikulasZelinka/followers","following_url":"https://api.github.com/users/MikulasZelinka/following{/other_user}","gists_url":"https://api.github.com/users/MikulasZelinka/gists{/gist_id}","starred_url":"https://api.github.com/users/MikulasZelinka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikulasZelinka/subscriptions","organizations_url":"https://api.github.com/users/MikulasZelinka/orgs","repos_url":"https://api.github.com/users/MikulasZelinka/repos","events_url":"https://api.github.com/users/MikulasZelinka/events{/privacy}","received_events_url":"https://api.github.com/users/MikulasZelinka/received_events","type":"User","site_admin":false},"created_at":"2018-06-13T10:42:05Z","updated_at":"2018-06-13T10:42:05Z","author_association":"NONE","body":"Thank you very much, problem solved :)\r\n\r\nI guess `hv.extension('bokeh')` should not in general be a part of the example as it is only required when doing the visualisation in the notebook (and it's not need for the server), is that correct?"}}
{"actor":{"display_login":"MikulasZelinka"}}