Skip to content

Commit f06e7b5

Browse files
committed
Stop doing weird protected imports for FF stuff.
1 parent 86fbe03 commit f06e7b5

File tree

13 files changed

+26
-64
lines changed

13 files changed

+26
-64
lines changed

plotly/figure_factory/_2d_density.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from __future__ import absolute_import
22

3+
from numbers import Number
4+
35
from plotly import exceptions
46
from plotly.figure_factory import utils
7+
from plotly.graph_objs import graph_objs
58

69

710
def make_linear_colorscale(colors):
@@ -83,8 +86,6 @@ def create_2d_density(x, y, colorscale='Earth', ncontours=20,
8386
py.iplot(fig, filename='use-parameters')
8487
```
8588
"""
86-
from plotly.graph_objs import graph_objs
87-
from numbers import Number
8889

8990
# validate x and y are filled with numbers only
9091
for array in [x, y]:

plotly/figure_factory/_annotated_heatmap.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from plotly import exceptions
44
from plotly.figure_factory import utils
5+
from plotly.graph_objs import graph_objs
56
from plotly.tools import _numpy_imported
67

78
if _numpy_imported:
@@ -82,8 +83,6 @@ def create_annotated_heatmap(z, x=None, y=None, annotation_text=None,
8283
py.iplot(figure)
8384
```
8485
"""
85-
# TODO: protected until #282
86-
from plotly.graph_objs import graph_objs
8786

8887
# Avoiding mutables in the call signature
8988
font_colors = font_colors if font_colors is not None else []
@@ -120,7 +119,6 @@ class _AnnotatedHeatmap(object):
120119
"""
121120
def __init__(self, z, x, y, annotation_text, colorscale,
122121
font_colors, reversescale, **kwargs):
123-
from plotly.graph_objs import graph_objs
124122

125123
self.z = z
126124
if x:
@@ -224,7 +222,6 @@ def make_annotations(self):
224222
:rtype (list[dict]) annotations: list of annotations for each cell of
225223
the heatmap
226224
"""
227-
from plotly.graph_objs import graph_objs
228225
min_text_color, max_text_color = _AnnotatedHeatmap.get_text_color(self)
229226
z_mid = _AnnotatedHeatmap.get_z_mid(self)
230227
annotations = []

plotly/figure_factory/_candlestick.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from plotly.figure_factory._ohlc import (_DEFAULT_INCREASING_COLOR,
55
_DEFAULT_DECREASING_COLOR,
66
validate_ohlc)
7+
from plotly.graph_objs import graph_objs
78

89

910
def make_increasing_candle(open, high, low, close, dates, **kwargs):
@@ -204,8 +205,6 @@ def create_candlestick(open, high, low, close, dates=None, direction='both',
204205
py.iplot(fig, filename='finance/simple-candlestick', validate=False)
205206
```
206207
"""
207-
# TODO: protected until #282
208-
from plotly.graph_objs import graph_objs
209208
if dates is not None:
210209
utils.validate_equal_length(open, high, low, close, dates)
211210
else:

plotly/figure_factory/_dendrogram.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections import OrderedDict
66

77
from plotly import exceptions
8+
from plotly.graph_objs import graph_objs
89
from plotly.tools import (_numpy_imported, _scipy_imported,
910
_scipy__cluster__hierarchy_imported,
1011
_scipy__spatial_imported)
@@ -106,8 +107,6 @@ class _Dendrogram(object):
106107
def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
107108
width="100%", height="100%", xaxis='xaxis', yaxis='yaxis',
108109
distfun=None, linkagefun=lambda x: sch.linkage(x, 'complete')):
109-
# TODO: protected until #282
110-
from plotly.graph_objs import graph_objs
111110
self.orientation = orientation
112111
self.labels = labels
113112
self.xaxis = xaxis
@@ -259,8 +258,6 @@ def get_dendrogram_traces(self, X, colorscale, distfun, linkagefun):
259258
(e) P['leaves']: left-to-right traversal of the leaves
260259
261260
"""
262-
# TODO: protected until #282
263-
from plotly.graph_objs import graph_objs
264261
d = distfun(X)
265262
Z = linkagefun(d)
266263
P = sch.dendrogram(Z, orientation=self.orientation,

plotly/figure_factory/_distplot.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from plotly import exceptions
44
from plotly.figure_factory import utils
5+
from plotly.graph_objs import graph_objs
56
from plotly.tools import _numpy_imported, _pandas_imported, _scipy_imported
67

78
if _numpy_imported:
@@ -27,12 +28,6 @@ def validate_distplot(hist_data, curve_type):
2728
:raises: (PlotlyError) If curve_type is not valid (i.e. not 'kde' or
2829
'normal').
2930
"""
30-
try:
31-
import pandas as pd
32-
_pandas_imported = True
33-
except ImportError:
34-
_pandas_imported = False
35-
3631
hist_data_types = (list,)
3732
if _numpy_imported:
3833
hist_data_types += (np.ndarray,)
@@ -174,8 +169,6 @@ def create_distplot(hist_data, group_labels, bin_size=1., curve_type='kde',
174169
validate=False)
175170
```
176171
"""
177-
# TODO: protected until #282
178-
from plotly.graph_objs import graph_objs
179172
validate_distplot(hist_data, curve_type)
180173
utils.validate_equal_length(hist_data, group_labels)
181174

plotly/figure_factory/_gantt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import absolute_import
22

3+
from numbers import Number
4+
35
from plotly import exceptions
46
from plotly.figure_factory import utils
57
from plotly.tools import _pandas_imported
@@ -181,7 +183,6 @@ def gantt_colorscale(chart, colors, title, index_col, show_colorbar, bar_width,
181183
"""
182184
Refer to FigureFactory.create_gantt() for docstring
183185
"""
184-
from numbers import Number
185186
if tasks is None:
186187
tasks = []
187188
if task_names is None:

plotly/figure_factory/_ohlc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
from plotly import exceptions
4+
from plotly.graph_objs import graph_objs
45
from plotly.figure_factory import utils
56

67

@@ -254,8 +255,6 @@ def create_ohlc(open, high, low, close, dates=None, direction='both',
254255
py.iplot(fig, filename='finance/simple-ohlc', validate=False)
255256
```
256257
"""
257-
# TODO: protected until #282
258-
from plotly.graph_objs import graph_objs
259258
if dates is not None:
260259
utils.validate_equal_length(open, high, low, close, dates)
261260
else:

plotly/figure_factory/_quiver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import math
44

55
from plotly import exceptions
6+
from plotly.graph_objs import graph_objs
67
from plotly.figure_factory import utils
78

89

@@ -88,8 +89,6 @@ def create_quiver(x, y, u, v, scale=.1, arrow_scale=.3,
8889
py.plot(fig, filename='quiver')
8990
```
9091
"""
91-
# TODO: protected until #282
92-
from plotly.graph_objs import graph_objs
9392
utils.validate_equal_length(x, y, u, v)
9493
utils.validate_positive_scalars(arrow_scale=arrow_scale, scale=scale)
9594

plotly/figure_factory/_scatterplot.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from plotly import exceptions
44
from plotly.figure_factory import utils
5+
from plotly.graph_objs import graph_objs
56
from plotly.tools import _pandas_imported, make_subplots
67

78
if _pandas_imported:
@@ -137,7 +138,6 @@ def scatterplot(dataframe, headers, diag, size, height, width, title,
137138
Returns fig for scatterplotmatrix without index
138139
139140
"""
140-
from plotly.graph_objs import graph_objs
141141
dim = len(dataframe)
142142
fig = make_subplots(rows=dim, cols=dim, print_grid=False)
143143
trace_list = []
@@ -219,7 +219,6 @@ def scatterplot_dict(dataframe, headers, diag, size,
219219
implies that a categorical approach should be taken
220220
221221
"""
222-
from plotly.graph_objs import graph_objs
223222

224223
theme = colormap
225224
dim = len(dataframe)
@@ -377,7 +376,6 @@ def scatterplot_theme(dataframe, headers, diag, size, height, width, title,
377376
Returns fig for scatterplotmatrix with both index and colormap picked
378377
379378
"""
380-
from plotly.graph_objs import graph_objs
381379

382380
# Check if index is made of string values
383381
if isinstance(index_vals[0], str):

plotly/figure_factory/_streamline.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from plotly import exceptions
66
from plotly.figure_factory import utils
7+
from plotly.graph_objs import graph_objs
78
from plotly.tools import _numpy_imported
89

910
if _numpy_imported:
@@ -118,8 +119,6 @@ def create_streamline(x, y, u, v, density=1, angle=math.pi / 9,
118119
py.plot(fig, filename='streamline')
119120
```
120121
"""
121-
# TODO: protected until #282
122-
from plotly.graph_objs import graph_objs
123122
utils.validate_equal_length(x, y)
124123
utils.validate_equal_length(u, v)
125124
validate_streamline(x, y)

plotly/figure_factory/_table.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
from plotly import exceptions
4+
from plotly.graph_objs import graph_objs
45
from plotly.tools import _pandas_imported
56

67
if _pandas_imported:
@@ -97,8 +98,6 @@ def create_table(table_text, colorscale=None, font_colors=None,
9798
py.iplot(table_simple)
9899
```
99100
"""
100-
# TODO: protected until #282
101-
from plotly.graph_objs import graph_objs
102101

103102
# Avoiding mutables in the call signature
104103
colorscale = \
@@ -139,7 +138,6 @@ class _Table(object):
139138
"""
140139
def __init__(self, table_text, colorscale, font_colors, index,
141140
index_title, annotation_offset, **kwargs):
142-
from plotly.graph_objs import graph_objs
143141
if _pandas_imported and isinstance(table_text, pd.DataFrame):
144142
headers = table_text.columns.tolist()
145143
table_text_index = table_text.index.tolist()
@@ -211,7 +209,6 @@ def make_table_annotations(self):
211209
:rtype (list) annotations: list of annotations for each cell of the
212210
table.
213211
"""
214-
from plotly.graph_objs import graph_objs
215212
table_matrix = _Table.get_table_matrix(self)
216213
all_font_colors = _Table.get_table_font_color(self)
217214
annotations = []

plotly/figure_factory/_trisurf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
from plotly import colors, exceptions
4+
from plotly.graph_objs import graph_objs
45
from plotly.tools import _numpy_imported
56

67
if _numpy_imported:
@@ -83,7 +84,6 @@ def trisurf(x, y, z, simplices, show_colorbar, edges_color, scale,
8384
if _numpy_imported is False:
8485
raise ImportError("FigureFactory._trisurf() requires "
8586
"numpy imported.")
86-
from plotly.graph_objs import graph_objs
8787
points3D = np.vstack((x, y, z)).T
8888
simplices = np.atleast_2d(simplices)
8989

@@ -455,7 +455,6 @@ def dist_origin(x, y, z):
455455
py.iplot(fig, filename="trisurf-plot-modern-art")
456456
```
457457
"""
458-
from plotly.graph_objs import graph_objs
459458

460459
# Validate colormap
461460
colors.validate_colors(colormap)

0 commit comments

Comments
 (0)