We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
UserWarning: Config option `use_jedi` not recognized by `IPCompleter`.
This error is show when I'm trying to import bokeh:
`hv.extension('bokeh')`

Product versions:
- numpy 1.16.4
- pandas 0.24.4
- bokeh 1.2.0
- holoviews 1.12.3
- hvplot 0.4.0

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `holoviews/ipython/__init__.py`
Content:
```
1 import os
2 from unittest import SkipTest
3 
4 import param
5 import holoviews
6 from pyviz_comms import nb_mime_js
7 from IPython import version_info
8 from param import ipython as param_ext
9 from IPython.display import HTML, publish_display_data
10 
11 from ..core.dimension import LabelledData
12 from ..core.tree import AttrTree
13 from ..core.options import Store
14 from ..element.comparison import ComparisonTestCase
15 from ..util import extension
16 from ..plotting.renderer import Renderer, MIME_TYPES
17 from .magics import load_magics
18 from .display_hooks import display  # noqa (API import)
19 from .display_hooks import pprint_display, png_display, svg_display
20 
21 
22 AttrTree._disabled_prefixes = ['_repr_','_ipython_canary_method_should_not_exist']
23 
24 def show_traceback():
25     """
26     Display the full traceback after an abbreviated traceback has occurred.
27     """
28     from .display_hooks import FULL_TRACEBACK
29     print(FULL_TRACEBACK)
30 
31 
32 class IPTestCase(ComparisonTestCase):
33     """
34     This class extends ComparisonTestCase to handle IPython specific
35     objects and support the execution of cells and magic.
36     """
37 
38     def setUp(self):
39         super(IPTestCase, self).setUp()
40         try:
41             import IPython
42             from IPython.display import HTML, SVG
43             self.ip = IPython.InteractiveShell()
44             if self.ip is None:
45                 raise TypeError()
46         except Exception:
47                 raise SkipTest("IPython could not be started")
48 
49         self.addTypeEqualityFunc(HTML, self.skip_comparison)
50         self.addTypeEqualityFunc(SVG,  self.skip_comparison)
51 
52     def skip_comparison(self, obj1, obj2, msg): pass
53 
54     def get_object(self, name):
55         obj = self.ip._object_find(name).obj
56         if obj is None:
57             raise self.failureException("Could not find object %s" % name)
58         return obj
59 
60 
61     def cell(self, line):
62         "Run an IPython cell"
63         self.ip.run_cell(line, silent=True)
64 
65     def cell_magic(self, *args, **kwargs):
66         "Run an IPython cell magic"
67         self.ip.run_cell_magic(*args, **kwargs)
68 
69 
70     def line_magic(self, *args, **kwargs):
71         "Run an IPython line magic"
72         self.ip.run_line_magic(*args, **kwargs)
73 
74 
75 class notebook_extension(extension):
76     """
77     Notebook specific extension to hv.extension that offers options for
78     controlling the notebook environment.
79     """
80 
81     css = param.String(default='', doc="Optional CSS rule set to apply to the notebook.")
82 
83     logo = param.Boolean(default=True, doc="Toggles display of HoloViews logo")
84 
85     inline = param.Boolean(default=True, doc="""
86         Whether to inline JS and CSS resources. 
87         If disabled, resources are loaded from CDN if one is available.""")
88 
89     width = param.Number(default=None, bounds=(0, 100), doc="""
90         Width of the notebook as a percentage of the browser screen window width.""")
91 
92     display_formats = param.List(default=['html'], doc="""
93         A list of formats that are rendered to the notebook where
94         multiple formats may be selected at once (although only one
95         format will be displayed).
96 
97         Although the 'html' format is supported across backends, other
98         formats supported by the current backend (e.g 'png' and 'svg'
99         using the matplotlib backend) may be used. This may be useful to
100         export figures to other formats such as PDF with nbconvert. """)
101 
102     allow_jedi_completion = param.Boolean(default=False, doc="""
103        Whether to allow jedi tab-completion to be enabled in IPython.
104        Disabled by default because many HoloViews features rely on
105        tab-completion machinery not supported when using jedi.""")
106 
107     case_sensitive_completion = param.Boolean(default=False, doc="""
108        Whether to monkey patch IPython to use the correct tab-completion
109        behavior. """)
110 
111     _loaded = False
112 
113     def __call__(self, *args, **params):
114         super(notebook_extension, self).__call__(*args, **params)
115         # Abort if IPython not found
116         try:
117             ip = params.pop('ip', None) or get_ipython() # noqa (get_ipython)
118         except:
119             return
120 
121         # Notebook archive relies on display hooks being set to work.
122         try:
123             if version_info[0] >= 4:
124                 import nbformat # noqa (ensures availability)
125             else:
126                 from IPython import nbformat # noqa (ensures availability)
127             try:
128                 from .archive import notebook_archive
129                 holoviews.archive = notebook_archive
130             except AttributeError as e:
131                 if str(e) != "module 'tornado.web' has no attribute 'asynchronous'":
132                     raise
133 
134         except ImportError:
135             pass
136 
137         # Not quite right, should be set when switching backends
138         if 'matplotlib' in Store.renderers and not notebook_extension._loaded:
139             svg_exporter = Store.renderers['matplotlib'].instance(holomap=None,fig='svg')
140             holoviews.archive.exporters = [svg_exporter] + holoviews.archive.exporters
141 
142         p = param.ParamOverrides(self, {k:v for k,v in params.items() if k!='config'})
143         if p.case_sensitive_completion:
144             from IPython.core import completer
145             completer.completions_sorting_key = self.completions_sorting_key
146         if not p.allow_jedi_completion:
147             ip.run_line_magic('config', 'IPCompleter.use_jedi = False')
148 
149         resources = self._get_resources(args, params)
150 
151         Store.display_formats = p.display_formats
152         if 'html' not in p.display_formats and len(p.display_formats) > 1:
153             msg = ('Output magic unable to control displayed format '
154                    'as IPython notebook uses fixed precedence '
155                    'between %r' % p.display_formats)
156             display(HTML('<b>Warning</b>: %s' % msg))
157 
158         loaded = notebook_extension._loaded
159         if loaded == False:
160             param_ext.load_ipython_extension(ip, verbose=False)
161             load_magics(ip)
162             Store.output_settings.initialize(list(Store.renderers.keys()))
163             Store.set_display_hook('html+js', LabelledData, pprint_display)
164             Store.set_display_hook('png', LabelledData, png_display)
165             Store.set_display_hook('svg', LabelledData, svg_display)
166             notebook_extension._loaded = True
167 
168         css = ''
169         if p.width is not None:
170             css += '<style>div.container { width: %s%% }</style>' % p.width
171         if p.css:
172             css += '<style>%s</style>' % p.css
173         if css:
174             display(HTML(css))
175 
176         resources = list(resources)
177         if len(resources) == 0: return
178 
179         Renderer.load_nb()
180         for r in [r for r in resources if r != 'holoviews']:
181             Store.renderers[r].load_nb(inline=p.inline)
182 
183         if hasattr(ip, 'kernel') and not loaded:
184             Renderer.comm_manager.get_client_comm(notebook_extension._process_comm_msg,
185                                                   "hv-extension-comm")
186 
187         # Create a message for the logo (if shown)
188         self.load_hvjs(logo=p.logo,
189                        bokeh_logo=  p.logo and ('bokeh' in resources),
190                        mpl_logo=    p.logo and (('matplotlib' in resources)
191                                                 or resources==['holoviews']),
192                        plotly_logo= p.logo and ('plotly' in resources),
193                        JS=('holoviews' in resources))
194 
195     @classmethod
196     def completions_sorting_key(cls, word):
197         "Fixed version of IPyton.completer.completions_sorting_key"
198         prio1, prio2 = 0, 0
199         if word.startswith('__'):  prio1 = 2
200         elif word.startswith('_'): prio1 = 1
201         if word.endswith('='):     prio1 = -1
202         if word.startswith('%%'):
203             if not "%" in word[2:]:
204                 word = word[2:];   prio2 = 2
205         elif word.startswith('%'):
206             if not "%" in word[1:]:
207                 word = word[1:];   prio2 = 1
208         return prio1, word, prio2
209 
210 
211     def _get_resources(self, args, params):
212         """
213         Finds the list of resources from the keyword parameters and pops
214         them out of the params dictionary.
215         """
216         resources = []
217         disabled = []
218         for resource in ['holoviews'] + list(Store.renderers.keys()):
219             if resource in args:
220                 resources.append(resource)
221 
222             if resource in params:
223                 setting = params.pop(resource)
224                 if setting is True and resource != 'matplotlib':
225                     if resource not in resources:
226                         resources.append(resource)
227                 if setting is False:
228                     disabled.append(resource)
229 
230         unmatched_args = set(args) - set(resources)
231         if unmatched_args:
232             display(HTML('<b>Warning:</b> Unrecognized resources %s'
233                          % ', '.join(unmatched_args)))
234 
235         resources = [r for r in resources if r not in disabled]
236         if ('holoviews' not in disabled) and ('holoviews' not in resources):
237             resources = ['holoviews'] + resources
238         return resources
239 
240     @classmethod
241     def load_hvjs(cls, logo=False, bokeh_logo=False, mpl_logo=False, plotly_logo=False,
242                   JS=True, message='HoloViewsJS successfully loaded.'):
243         """
244         Displays javascript and CSS to initialize HoloViews widgets.
245         """
246         import jinja2
247         # Evaluate load_notebook.html template with widgetjs code
248         if JS:
249             widgetjs, widgetcss = Renderer.html_assets(extras=False, backends=[], script=True)
250         else:
251             widgetjs, widgetcss = '', ''
252 
253         # Add classic notebook MIME renderer
254         widgetjs += nb_mime_js
255 
256         templateLoader = jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
257         jinjaEnv = jinja2.Environment(loader=templateLoader)
258         template = jinjaEnv.get_template('load_notebook.html')
259         html = template.render({'widgetcss':   widgetcss,
260                                 'logo':        logo,
261                                 'bokeh_logo':  bokeh_logo,
262                                 'mpl_logo':    mpl_logo,
263                                 'plotly_logo': plotly_logo,
264                                 'message':     message})
265         publish_display_data(data={'text/html': html})
266 
267         # Vanilla JS mime type is only consumed by classic notebook
268         # Custom mime type is only consumed by JupyterLab
269         if JS:
270             mimebundle = {
271                 MIME_TYPES['js']           : widgetjs,
272                 MIME_TYPES['jlab-hv-load'] : widgetjs
273             }
274             publish_display_data(data=mimebundle)
275 
276 
277     @param.parameterized.bothmethod
278     def tab_completion_docstring(self_or_cls):
279         """
280         Generates a docstring that can be used to enable tab-completion
281         of resources.
282         """
283         elements = ['%s=Boolean' %k for k in list(Store.renderers.keys())]
284         for name, p in self_or_cls.param.objects().items():
285             param_type = p.__class__.__name__
286             elements.append("%s=%s" % (name, param_type))
287 
288         return "params(%s)" % ', '.join(['holoviews=Boolean'] + elements)
289 
290 
291 notebook_extension.__doc__ = notebook_extension.tab_completion_docstring()
292 notebook_extension.add_delete_action(Renderer._delete_plot)
293 
294 
295 def load_ipython_extension(ip):
296     notebook_extension(ip=ip)
297 
298 def unload_ipython_extension(ip):
299     notebook_extension._loaded = False
300
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/holoviews/ipython/__init__.py b/holoviews/ipython/__init__.py
--- a/holoviews/ipython/__init__.py
+++ b/holoviews/ipython/__init__.py
@@ -3,10 +3,12 @@
 
 import param
 import holoviews
-from pyviz_comms import nb_mime_js
+
 from IPython import version_info
-from param import ipython as param_ext
+from IPython.core.completer import IPCompleter
 from IPython.display import HTML, publish_display_data
+from param import ipython as param_ext
+from pyviz_comms import nb_mime_js
 
 from ..core.dimension import LabelledData
 from ..core.tree import AttrTree
@@ -143,7 +145,7 @@
         if p.case_sensitive_completion:
             from IPython.core import completer
             completer.completions_sorting_key = self.completions_sorting_key
-        if not p.allow_jedi_completion:
+        if not p.allow_jedi_completion and hasattr(IPCompleter, 'use_jedi'):
             ip.run_line_magic('config', 'IPCompleter.use_jedi = False')
 
         resources = self._get_resources(args, params)

{"golden_diff": "diff --git a/holoviews/ipython/__init__.py b/holoviews/ipython/__init__.py\n--- a/holoviews/ipython/__init__.py\n+++ b/holoviews/ipython/__init__.py\n@@ -3,10 +3,12 @@\n \n import param\n import holoviews\n-from pyviz_comms import nb_mime_js\n+\n from IPython import version_info\n-from param import ipython as param_ext\n+from IPython.core.completer import IPCompleter\n from IPython.display import HTML, publish_display_data\n+from param import ipython as param_ext\n+from pyviz_comms import nb_mime_js\n \n from ..core.dimension import LabelledData\n from ..core.tree import AttrTree\n@@ -143,7 +145,7 @@\n         if p.case_sensitive_completion:\n             from IPython.core import completer\n             completer.completions_sorting_key = self.completions_sorting_key\n-        if not p.allow_jedi_completion:\n+        if not p.allow_jedi_completion and hasattr(IPCompleter, 'use_jedi'):\n             ip.run_line_magic('config', 'IPCompleter.use_jedi = False')\n \n         resources = self._get_resources(args, params)\n", "issue": "UserWarning: Config option `use_jedi` not recognized by `IPCompleter`.\nThis error is show when I'm trying to import bokeh:\r\n`hv.extension('bokeh')`\r\n\r\nProduct versions:\r\n- numpy 1.16.4\r\n- pandas 0.24.4\r\n- bokeh 1.2.0\r\n- holoviews 1.12.3\r\n- hvplot 0.4.0\n", "before_files": [{"content": "import os\nfrom unittest import SkipTest\n\nimport param\nimport holoviews\nfrom pyviz_comms import nb_mime_js\nfrom IPython import version_info\nfrom param import ipython as param_ext\nfrom IPython.display import HTML, publish_display_data\n\nfrom ..core.dimension import LabelledData\nfrom ..core.tree import AttrTree\nfrom ..core.options import Store\nfrom ..element.comparison import ComparisonTestCase\nfrom ..util import extension\nfrom ..plotting.renderer import Renderer, MIME_TYPES\nfrom .magics import load_magics\nfrom .display_hooks import display  # noqa (API import)\nfrom .display_hooks import pprint_display, png_display, svg_display\n\n\nAttrTree._disabled_prefixes = ['_repr_','_ipython_canary_method_should_not_exist']\n\ndef show_traceback():\n    \"\"\"\n    Display the full traceback after an abbreviated traceback has occurred.\n    \"\"\"\n    from .display_hooks import FULL_TRACEBACK\n    print(FULL_TRACEBACK)\n\n\nclass IPTestCase(ComparisonTestCase):\n    \"\"\"\n    This class extends ComparisonTestCase to handle IPython specific\n    objects and support the execution of cells and magic.\n    \"\"\"\n\n    def setUp(self):\n        super(IPTestCase, self).setUp()\n        try:\n            import IPython\n            from IPython.display import HTML, SVG\n            self.ip = IPython.InteractiveShell()\n            if self.ip is None:\n                raise TypeError()\n        except Exception:\n                raise SkipTest(\"IPython could not be started\")\n\n        self.addTypeEqualityFunc(HTML, self.skip_comparison)\n        self.addTypeEqualityFunc(SVG,  self.skip_comparison)\n\n    def skip_comparison(self, obj1, obj2, msg): pass\n\n    def get_object(self, name):\n        obj = self.ip._object_find(name).obj\n        if obj is None:\n            raise self.failureException(\"Could not find object %s\" % name)\n        return obj\n\n\n    def cell(self, line):\n        \"Run an IPython cell\"\n        self.ip.run_cell(line, silent=True)\n\n    def cell_magic(self, *args, **kwargs):\n        \"Run an IPython cell magic\"\n        self.ip.run_cell_magic(*args, **kwargs)\n\n\n    def line_magic(self, *args, **kwargs):\n        \"Run an IPython line magic\"\n        self.ip.run_line_magic(*args, **kwargs)\n\n\nclass notebook_extension(extension):\n    \"\"\"\n    Notebook specific extension to hv.extension that offers options for\n    controlling the notebook environment.\n    \"\"\"\n\n    css = param.String(default='', doc=\"Optional CSS rule set to apply to the notebook.\")\n\n    logo = param.Boolean(default=True, doc=\"Toggles display of HoloViews logo\")\n\n    inline = param.Boolean(default=True, doc=\"\"\"\n        Whether to inline JS and CSS resources. \n        If disabled, resources are loaded from CDN if one is available.\"\"\")\n\n    width = param.Number(default=None, bounds=(0, 100), doc=\"\"\"\n        Width of the notebook as a percentage of the browser screen window width.\"\"\")\n\n    display_formats = param.List(default=['html'], doc=\"\"\"\n        A list of formats that are rendered to the notebook where\n        multiple formats may be selected at once (although only one\n        format will be displayed).\n\n        Although the 'html' format is supported across backends, other\n        formats supported by the current backend (e.g 'png' and 'svg'\n        using the matplotlib backend) may be used. This may be useful to\n        export figures to other formats such as PDF with nbconvert. \"\"\")\n\n    allow_jedi_completion = param.Boolean(default=False, doc=\"\"\"\n       Whether to allow jedi tab-completion to be enabled in IPython.\n       Disabled by default because many HoloViews features rely on\n       tab-completion machinery not supported when using jedi.\"\"\")\n\n    case_sensitive_completion = param.Boolean(default=False, doc=\"\"\"\n       Whether to monkey patch IPython to use the correct tab-completion\n       behavior. \"\"\")\n\n    _loaded = False\n\n    def __call__(self, *args, **params):\n        super(notebook_extension, self).__call__(*args, **params)\n        # Abort if IPython not found\n        try:\n            ip = params.pop('ip', None) or get_ipython() # noqa (get_ipython)\n        except:\n            return\n\n        # Notebook archive relies on display hooks being set to work.\n        try:\n            if version_info[0] >= 4:\n                import nbformat # noqa (ensures availability)\n            else:\n                from IPython import nbformat # noqa (ensures availability)\n            try:\n                from .archive import notebook_archive\n                holoviews.archive = notebook_archive\n            except AttributeError as e:\n                if str(e) != \"module 'tornado.web' has no attribute 'asynchronous'\":\n                    raise\n\n        except ImportError:\n            pass\n\n        # Not quite right, should be set when switching backends\n        if 'matplotlib' in Store.renderers and not notebook_extension._loaded:\n            svg_exporter = Store.renderers['matplotlib'].instance(holomap=None,fig='svg')\n            holoviews.archive.exporters = [svg_exporter] + holoviews.archive.exporters\n\n        p = param.ParamOverrides(self, {k:v for k,v in params.items() if k!='config'})\n        if p.case_sensitive_completion:\n            from IPython.core import completer\n            completer.completions_sorting_key = self.completions_sorting_key\n        if not p.allow_jedi_completion:\n            ip.run_line_magic('config', 'IPCompleter.use_jedi = False')\n\n        resources = self._get_resources(args, params)\n\n        Store.display_formats = p.display_formats\n        if 'html' not in p.display_formats and len(p.display_formats) > 1:\n            msg = ('Output magic unable to control displayed format '\n                   'as IPython notebook uses fixed precedence '\n                   'between %r' % p.display_formats)\n            display(HTML('<b>Warning</b>: %s' % msg))\n\n        loaded = notebook_extension._loaded\n        if loaded == False:\n            param_ext.load_ipython_extension(ip, verbose=False)\n            load_magics(ip)\n            Store.output_settings.initialize(list(Store.renderers.keys()))\n            Store.set_display_hook('html+js', LabelledData, pprint_display)\n            Store.set_display_hook('png', LabelledData, png_display)\n            Store.set_display_hook('svg', LabelledData, svg_display)\n            notebook_extension._loaded = True\n\n        css = ''\n        if p.width is not None:\n            css += '<style>div.container { width: %s%% }</style>' % p.width\n        if p.css:\n            css += '<style>%s</style>' % p.css\n        if css:\n            display(HTML(css))\n\n        resources = list(resources)\n        if len(resources) == 0: return\n\n        Renderer.load_nb()\n        for r in [r for r in resources if r != 'holoviews']:\n            Store.renderers[r].load_nb(inline=p.inline)\n\n        if hasattr(ip, 'kernel') and not loaded:\n            Renderer.comm_manager.get_client_comm(notebook_extension._process_comm_msg,\n                                                  \"hv-extension-comm\")\n\n        # Create a message for the logo (if shown)\n        self.load_hvjs(logo=p.logo,\n                       bokeh_logo=  p.logo and ('bokeh' in resources),\n                       mpl_logo=    p.logo and (('matplotlib' in resources)\n                                                or resources==['holoviews']),\n                       plotly_logo= p.logo and ('plotly' in resources),\n                       JS=('holoviews' in resources))\n\n    @classmethod\n    def completions_sorting_key(cls, word):\n        \"Fixed version of IPyton.completer.completions_sorting_key\"\n        prio1, prio2 = 0, 0\n        if word.startswith('__'):  prio1 = 2\n        elif word.startswith('_'): prio1 = 1\n        if word.endswith('='):     prio1 = -1\n        if word.startswith('%%'):\n            if not \"%\" in word[2:]:\n                word = word[2:];   prio2 = 2\n        elif word.startswith('%'):\n            if not \"%\" in word[1:]:\n                word = word[1:];   prio2 = 1\n        return prio1, word, prio2\n\n\n    def _get_resources(self, args, params):\n        \"\"\"\n        Finds the list of resources from the keyword parameters and pops\n        them out of the params dictionary.\n        \"\"\"\n        resources = []\n        disabled = []\n        for resource in ['holoviews'] + list(Store.renderers.keys()):\n            if resource in args:\n                resources.append(resource)\n\n            if resource in params:\n                setting = params.pop(resource)\n                if setting is True and resource != 'matplotlib':\n                    if resource not in resources:\n                        resources.append(resource)\n                if setting is False:\n                    disabled.append(resource)\n\n        unmatched_args = set(args) - set(resources)\n        if unmatched_args:\n            display(HTML('<b>Warning:</b> Unrecognized resources %s'\n                         % ', '.join(unmatched_args)))\n\n        resources = [r for r in resources if r not in disabled]\n        if ('holoviews' not in disabled) and ('holoviews' not in resources):\n            resources = ['holoviews'] + resources\n        return resources\n\n    @classmethod\n    def load_hvjs(cls, logo=False, bokeh_logo=False, mpl_logo=False, plotly_logo=False,\n                  JS=True, message='HoloViewsJS successfully loaded.'):\n        \"\"\"\n        Displays javascript and CSS to initialize HoloViews widgets.\n        \"\"\"\n        import jinja2\n        # Evaluate load_notebook.html template with widgetjs code\n        if JS:\n            widgetjs, widgetcss = Renderer.html_assets(extras=False, backends=[], script=True)\n        else:\n            widgetjs, widgetcss = '', ''\n\n        # Add classic notebook MIME renderer\n        widgetjs += nb_mime_js\n\n        templateLoader = jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))\n        jinjaEnv = jinja2.Environment(loader=templateLoader)\n        template = jinjaEnv.get_template('load_notebook.html')\n        html = template.render({'widgetcss':   widgetcss,\n                                'logo':        logo,\n                                'bokeh_logo':  bokeh_logo,\n                                'mpl_logo':    mpl_logo,\n                                'plotly_logo': plotly_logo,\n                                'message':     message})\n        publish_display_data(data={'text/html': html})\n\n        # Vanilla JS mime type is only consumed by classic notebook\n        # Custom mime type is only consumed by JupyterLab\n        if JS:\n            mimebundle = {\n                MIME_TYPES['js']           : widgetjs,\n                MIME_TYPES['jlab-hv-load'] : widgetjs\n            }\n            publish_display_data(data=mimebundle)\n\n\n    @param.parameterized.bothmethod\n    def tab_completion_docstring(self_or_cls):\n        \"\"\"\n        Generates a docstring that can be used to enable tab-completion\n        of resources.\n        \"\"\"\n        elements = ['%s=Boolean' %k for k in list(Store.renderers.keys())]\n        for name, p in self_or_cls.param.objects().items():\n            param_type = p.__class__.__name__\n            elements.append(\"%s=%s\" % (name, param_type))\n\n        return \"params(%s)\" % ', '.join(['holoviews=Boolean'] + elements)\n\n\nnotebook_extension.__doc__ = notebook_extension.tab_completion_docstring()\nnotebook_extension.add_delete_action(Renderer._delete_plot)\n\n\ndef load_ipython_extension(ip):\n    notebook_extension(ip=ip)\n\ndef unload_ipython_extension(ip):\n    notebook_extension._loaded = False\n", "path": "holoviews/ipython/__init__.py"}], "after_files": [{"content": "import os\nfrom unittest import SkipTest\n\nimport param\nimport holoviews\n\nfrom IPython import version_info\nfrom IPython.core.completer import IPCompleter\nfrom IPython.display import HTML, publish_display_data\nfrom param import ipython as param_ext\nfrom pyviz_comms import nb_mime_js\n\nfrom ..core.dimension import LabelledData\nfrom ..core.tree import AttrTree\nfrom ..core.options import Store\nfrom ..element.comparison import ComparisonTestCase\nfrom ..util import extension\nfrom ..plotting.renderer import Renderer, MIME_TYPES\nfrom .magics import load_magics\nfrom .display_hooks import display  # noqa (API import)\nfrom .display_hooks import pprint_display, png_display, svg_display\n\n\nAttrTree._disabled_prefixes = ['_repr_','_ipython_canary_method_should_not_exist']\n\ndef show_traceback():\n    \"\"\"\n    Display the full traceback after an abbreviated traceback has occurred.\n    \"\"\"\n    from .display_hooks import FULL_TRACEBACK\n    print(FULL_TRACEBACK)\n\n\nclass IPTestCase(ComparisonTestCase):\n    \"\"\"\n    This class extends ComparisonTestCase to handle IPython specific\n    objects and support the execution of cells and magic.\n    \"\"\"\n\n    def setUp(self):\n        super(IPTestCase, self).setUp()\n        try:\n            import IPython\n            from IPython.display import HTML, SVG\n            self.ip = IPython.InteractiveShell()\n            if self.ip is None:\n                raise TypeError()\n        except Exception:\n                raise SkipTest(\"IPython could not be started\")\n\n        self.addTypeEqualityFunc(HTML, self.skip_comparison)\n        self.addTypeEqualityFunc(SVG,  self.skip_comparison)\n\n    def skip_comparison(self, obj1, obj2, msg): pass\n\n    def get_object(self, name):\n        obj = self.ip._object_find(name).obj\n        if obj is None:\n            raise self.failureException(\"Could not find object %s\" % name)\n        return obj\n\n\n    def cell(self, line):\n        \"Run an IPython cell\"\n        self.ip.run_cell(line, silent=True)\n\n    def cell_magic(self, *args, **kwargs):\n        \"Run an IPython cell magic\"\n        self.ip.run_cell_magic(*args, **kwargs)\n\n\n    def line_magic(self, *args, **kwargs):\n        \"Run an IPython line magic\"\n        self.ip.run_line_magic(*args, **kwargs)\n\n\nclass notebook_extension(extension):\n    \"\"\"\n    Notebook specific extension to hv.extension that offers options for\n    controlling the notebook environment.\n    \"\"\"\n\n    css = param.String(default='', doc=\"Optional CSS rule set to apply to the notebook.\")\n\n    logo = param.Boolean(default=True, doc=\"Toggles display of HoloViews logo\")\n\n    inline = param.Boolean(default=True, doc=\"\"\"\n        Whether to inline JS and CSS resources. \n        If disabled, resources are loaded from CDN if one is available.\"\"\")\n\n    width = param.Number(default=None, bounds=(0, 100), doc=\"\"\"\n        Width of the notebook as a percentage of the browser screen window width.\"\"\")\n\n    display_formats = param.List(default=['html'], doc=\"\"\"\n        A list of formats that are rendered to the notebook where\n        multiple formats may be selected at once (although only one\n        format will be displayed).\n\n        Although the 'html' format is supported across backends, other\n        formats supported by the current backend (e.g 'png' and 'svg'\n        using the matplotlib backend) may be used. This may be useful to\n        export figures to other formats such as PDF with nbconvert. \"\"\")\n\n    allow_jedi_completion = param.Boolean(default=False, doc=\"\"\"\n       Whether to allow jedi tab-completion to be enabled in IPython.\n       Disabled by default because many HoloViews features rely on\n       tab-completion machinery not supported when using jedi.\"\"\")\n\n    case_sensitive_completion = param.Boolean(default=False, doc=\"\"\"\n       Whether to monkey patch IPython to use the correct tab-completion\n       behavior. \"\"\")\n\n    _loaded = False\n\n    def __call__(self, *args, **params):\n        super(notebook_extension, self).__call__(*args, **params)\n        # Abort if IPython not found\n        try:\n            ip = params.pop('ip', None) or get_ipython() # noqa (get_ipython)\n        except:\n            return\n\n        # Notebook archive relies on display hooks being set to work.\n        try:\n            if version_info[0] >= 4:\n                import nbformat # noqa (ensures availability)\n            else:\n                from IPython import nbformat # noqa (ensures availability)\n            try:\n                from .archive import notebook_archive\n                holoviews.archive = notebook_archive\n            except AttributeError as e:\n                if str(e) != \"module 'tornado.web' has no attribute 'asynchronous'\":\n                    raise\n\n        except ImportError:\n            pass\n\n        # Not quite right, should be set when switching backends\n        if 'matplotlib' in Store.renderers and not notebook_extension._loaded:\n            svg_exporter = Store.renderers['matplotlib'].instance(holomap=None,fig='svg')\n            holoviews.archive.exporters = [svg_exporter] + holoviews.archive.exporters\n\n        p = param.ParamOverrides(self, {k:v for k,v in params.items() if k!='config'})\n        if p.case_sensitive_completion:\n            from IPython.core import completer\n            completer.completions_sorting_key = self.completions_sorting_key\n        if not p.allow_jedi_completion and hasattr(IPCompleter, 'use_jedi'):\n            ip.run_line_magic('config', 'IPCompleter.use_jedi = False')\n\n        resources = self._get_resources(args, params)\n\n        Store.display_formats = p.display_formats\n        if 'html' not in p.display_formats and len(p.display_formats) > 1:\n            msg = ('Output magic unable to control displayed format '\n                   'as IPython notebook uses fixed precedence '\n                   'between %r' % p.display_formats)\n            display(HTML('<b>Warning</b>: %s' % msg))\n\n        loaded = notebook_extension._loaded\n        if loaded == False:\n            param_ext.load_ipython_extension(ip, verbose=False)\n            load_magics(ip)\n            Store.output_settings.initialize(list(Store.renderers.keys()))\n            Store.set_display_hook('html+js', LabelledData, pprint_display)\n            Store.set_display_hook('png', LabelledData, png_display)\n            Store.set_display_hook('svg', LabelledData, svg_display)\n            notebook_extension._loaded = True\n\n        css = ''\n        if p.width is not None:\n            css += '<style>div.container { width: %s%% }</style>' % p.width\n        if p.css:\n            css += '<style>%s</style>' % p.css\n        if css:\n            display(HTML(css))\n\n        resources = list(resources)\n        if len(resources) == 0: return\n\n        Renderer.load_nb()\n        for r in [r for r in resources if r != 'holoviews']:\n            Store.renderers[r].load_nb(inline=p.inline)\n\n        if hasattr(ip, 'kernel') and not loaded:\n            Renderer.comm_manager.get_client_comm(notebook_extension._process_comm_msg,\n                                                  \"hv-extension-comm\")\n\n        # Create a message for the logo (if shown)\n        self.load_hvjs(logo=p.logo,\n                       bokeh_logo=  p.logo and ('bokeh' in resources),\n                       mpl_logo=    p.logo and (('matplotlib' in resources)\n                                                or resources==['holoviews']),\n                       plotly_logo= p.logo and ('plotly' in resources),\n                       JS=('holoviews' in resources))\n\n    @classmethod\n    def completions_sorting_key(cls, word):\n        \"Fixed version of IPyton.completer.completions_sorting_key\"\n        prio1, prio2 = 0, 0\n        if word.startswith('__'):  prio1 = 2\n        elif word.startswith('_'): prio1 = 1\n        if word.endswith('='):     prio1 = -1\n        if word.startswith('%%'):\n            if not \"%\" in word[2:]:\n                word = word[2:];   prio2 = 2\n        elif word.startswith('%'):\n            if not \"%\" in word[1:]:\n                word = word[1:];   prio2 = 1\n        return prio1, word, prio2\n\n\n    def _get_resources(self, args, params):\n        \"\"\"\n        Finds the list of resources from the keyword parameters and pops\n        them out of the params dictionary.\n        \"\"\"\n        resources = []\n        disabled = []\n        for resource in ['holoviews'] + list(Store.renderers.keys()):\n            if resource in args:\n                resources.append(resource)\n\n            if resource in params:\n                setting = params.pop(resource)\n                if setting is True and resource != 'matplotlib':\n                    if resource not in resources:\n                        resources.append(resource)\n                if setting is False:\n                    disabled.append(resource)\n\n        unmatched_args = set(args) - set(resources)\n        if unmatched_args:\n            display(HTML('<b>Warning:</b> Unrecognized resources %s'\n                         % ', '.join(unmatched_args)))\n\n        resources = [r for r in resources if r not in disabled]\n        if ('holoviews' not in disabled) and ('holoviews' not in resources):\n            resources = ['holoviews'] + resources\n        return resources\n\n    @classmethod\n    def load_hvjs(cls, logo=False, bokeh_logo=False, mpl_logo=False, plotly_logo=False,\n                  JS=True, message='HoloViewsJS successfully loaded.'):\n        \"\"\"\n        Displays javascript and CSS to initialize HoloViews widgets.\n        \"\"\"\n        import jinja2\n        # Evaluate load_notebook.html template with widgetjs code\n        if JS:\n            widgetjs, widgetcss = Renderer.html_assets(extras=False, backends=[], script=True)\n        else:\n            widgetjs, widgetcss = '', ''\n\n        # Add classic notebook MIME renderer\n        widgetjs += nb_mime_js\n\n        templateLoader = jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))\n        jinjaEnv = jinja2.Environment(loader=templateLoader)\n        template = jinjaEnv.get_template('load_notebook.html')\n        html = template.render({'widgetcss':   widgetcss,\n                                'logo':        logo,\n                                'bokeh_logo':  bokeh_logo,\n                                'mpl_logo':    mpl_logo,\n                                'plotly_logo': plotly_logo,\n                                'message':     message})\n        publish_display_data(data={'text/html': html})\n\n        # Vanilla JS mime type is only consumed by classic notebook\n        # Custom mime type is only consumed by JupyterLab\n        if JS:\n            mimebundle = {\n                MIME_TYPES['js']           : widgetjs,\n                MIME_TYPES['jlab-hv-load'] : widgetjs\n            }\n            publish_display_data(data=mimebundle)\n\n\n    @param.parameterized.bothmethod\n    def tab_completion_docstring(self_or_cls):\n        \"\"\"\n        Generates a docstring that can be used to enable tab-completion\n        of resources.\n        \"\"\"\n        elements = ['%s=Boolean' %k for k in list(Store.renderers.keys())]\n        for name, p in self_or_cls.param.objects().items():\n            param_type = p.__class__.__name__\n            elements.append(\"%s=%s\" % (name, param_type))\n\n        return \"params(%s)\" % ', '.join(['holoviews=Boolean'] + elements)\n\n\nnotebook_extension.__doc__ = notebook_extension.tab_completion_docstring()\nnotebook_extension.add_delete_action(Renderer._delete_plot)\n\n\ndef load_ipython_extension(ip):\n    notebook_extension(ip=ip)\n\ndef unload_ipython_extension(ip):\n    notebook_extension._loaded = False\n", "path": "holoviews/ipython/__init__.py"}]}