Skip to content

Commit 2de17c3

Browse files
committed
Offline: Cleanup unused code
1 parent 91e74fd commit 2de17c3

File tree

1 file changed

+12
-35
lines changed

1 file changed

+12
-35
lines changed

plotly/offline/offline.py

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,11 @@
1414

1515
import plotly
1616
from plotly import tools, utils
17-
from plotly.exceptions import PlotlyError
1817

18+
import IPython
19+
from IPython.display import HTML, display
1920

20-
try:
21-
import IPython
22-
_ipython_imported = True
23-
except ImportError:
24-
_ipython_imported = False
25-
26-
try:
27-
import matplotlib
28-
_matplotlib_imported = True
29-
except ImportError:
30-
_matplotlib_imported = False
31-
32-
33-
__PLOTLY_OFFLINE_INITIALIZED = False
21+
import matplotlib
3422

3523

3624
def download_plotlyjs(download_url):
@@ -79,21 +67,13 @@ def init_notebook_mode():
7967
to load the necessary javascript files for creating
8068
Plotly graphs with plotly.offline.iplot.
8169
"""
82-
if not tools._ipython_imported:
83-
raise ImportError('`iplot` can only run inside an IPython Notebook.')
84-
from IPython.display import HTML, display
85-
86-
global __PLOTLY_OFFLINE_INITIALIZED
87-
if not __PLOTLY_OFFLINE_INITIALIZED:
88-
display(HTML("<script type='text/javascript'>" +
89-
"define('plotly', function(require, exports, module) {" +
90-
get_plotlyjs() +
91-
"});" +
92-
"require(['plotly'], function(Plotly) {" +
93-
"window.Plotly = Plotly;" +
94-
"});" +
95-
"</script>"))
96-
__PLOTLY_OFFLINE_INITIALIZED = True
70+
warnings.warn('''
71+
`init_notebook_mode` is deprecated and will be removed in the
72+
next release. Notebook mode is now automatically initialized when
73+
notebook methods are invoked, so it is no
74+
longer necessary to manually initialize.
75+
''', DeprecationWarning)
76+
pass
9777

9878

9979
def _plot_html(figure_or_data, show_link, link_text,
@@ -433,11 +413,9 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False,
433413
434414
Example:
435415
```
436-
from plotly.offline import init_notebook_mode, iplot_mpl
416+
from plotly.offline import iplot_mpl
437417
import matplotlib.pyplot as plt
438418
439-
init_notebook_mode()
440-
441419
fig = plt.figure()
442420
x = [10, 15, 20, 25, 30]
443421
y = [100, 250, 200, 150, 300]
@@ -468,10 +446,9 @@ def enable_mpl_offline(resize=False, strip_style=False,
468446
469447
Example:
470448
```
471-
from plotly.offline import init_notebook_mode, enable_mpl_offline
449+
from plotly.offline import enable_mpl_offline
472450
import matplotlib.pyplot as plt
473451
474-
init_notebook_mode()
475452
enable_mpl_offline()
476453
477454
fig = plt.figure()

0 commit comments

Comments
 (0)