Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce5b42c

Browse files
committed
narrower exception handling
1 parent 3d95463 commit ce5b42c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

plotly/offline.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def init_notebook_mode():
5050
to load the necessary javascript files for creating
5151
Plotly graphs with plotly.offline.iplot.
5252
"""
53+
if not
5354
from IPython.display import HTML, display
5455

5556
if not os.path.exists(PLOTLY_OFFLINE_BUNDLE):
@@ -117,14 +118,17 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly'):
117118
height = layout.get('height', 525)
118119
try:
119120
float(width)
120-
width = str(width) + 'px'
121-
except:
121+
except (ValueError, TypeError):
122122
pass
123+
else:
124+
width = str(width) + 'px'
125+
123126
try:
124-
float(height)
125-
height = str(height) + 'px'
126-
except:
127+
float(width)
128+
except (ValueError, TypeError):
127129
pass
130+
else:
131+
width = str(width) + 'px'
128132

129133
plotdivid = uuid.uuid4()
130134
jdata = json.dumps(data, cls=utils.PlotlyJSONEncoder)

0 commit comments

Comments
 (0)