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

Skip to content

Commit 8b95a0b

Browse files
committed
Change FigureFactory import, auto refact was poor.
1 parent 4c6603f commit 8b95a0b

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

plotly/tests/test_optional/test_figure_factory.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from unittest import TestCase
22
from plotly.graph_objs import graph_objs as go
33
from plotly.exceptions import PlotlyError
4-
import plotly.graph_objs.figure_factory
4+
from plotly.graph_objs.figure_factory import FigureFactory
55

66
import plotly.tools as tls
77
from plotly.tests.test_optional.optional_utils import NumpyTestUtilsMixin
@@ -22,7 +22,7 @@ def test_wrong_curve_type(self):
2222
'curve_type': 'curve'}
2323
self.assertRaisesRegexp(PlotlyError, "curve_type must be defined as "
2424
"'kde' or 'normal'",
25-
plotly.graph_objs.figure_factory.FigureFactory.create_distplot, **kwargs)
25+
FigureFactory.create_distplot, **kwargs)
2626

2727
def test_wrong_histdata_format(self):
2828

@@ -31,25 +31,25 @@ def test_wrong_histdata_format(self):
3131
# will fail)
3232

3333
kwargs = {'hist_data': [1, 2, 3], 'group_labels': ['group']}
34-
self.assertRaises(PlotlyError, plotly.graph_objs.figure_factory.FigureFactory.create_distplot,
34+
self.assertRaises(PlotlyError, FigureFactory.create_distplot,
3535
**kwargs)
3636

3737
def test_unequal_data_label_length(self):
3838
kwargs = {'hist_data': [[1, 2]], 'group_labels': ['group', 'group2']}
39-
self.assertRaises(PlotlyError, plotly.graph_objs.figure_factory.FigureFactory.create_distplot,
39+
self.assertRaises(PlotlyError, FigureFactory.create_distplot,
4040
**kwargs)
4141

4242
kwargs = {'hist_data': [[1, 2], [1, 2, 3]], 'group_labels': ['group']}
43-
self.assertRaises(PlotlyError, plotly.graph_objs.figure_factory.FigureFactory.create_distplot,
43+
self.assertRaises(PlotlyError, FigureFactory.create_distplot,
4444
**kwargs)
4545

4646
def test_simple_distplot(self):
4747

4848
# we should be able to create a single distplot with a simple dataset
4949
# and default kwargs
5050

51-
dp = plotly.graph_objs.figure_factory.FigureFactory.create_distplot(hist_data=[[1, 2, 2, 3]],
52-
group_labels=['distplot'])
51+
dp = FigureFactory.create_distplot(hist_data=[[1, 2, 2, 3]],
52+
group_labels=['distplot'])
5353
expected_dp_layout = {'barmode': 'overlay',
5454
'hovermode': 'closest',
5555
'legend': {'traceorder': 'reversed'},
@@ -104,8 +104,8 @@ def test_distplot_more_args(self):
104104
hist_data = [hist1_x] + [hist2_x]
105105
group_labels = ['2012', '2013']
106106

107-
dp = plotly.graph_objs.figure_factory.FigureFactory.create_distplot(hist_data, group_labels,
108-
show_rug=False, bin_size=.2)
107+
dp = FigureFactory.create_distplot(hist_data, group_labels,
108+
show_rug=False, bin_size=.2)
109109
dp['layout'].update(title='Dist Plot')
110110

111111
expected_dp_layout = {'barmode': 'overlay',
@@ -161,7 +161,7 @@ def test_wrong_arrow_scale(self):
161161
'u': [[-1, -5], [-1, -5]],
162162
'v': [[1, 1], [-3, -3]],
163163
'arrow_scale': 0}
164-
self.assertRaises(ValueError, plotly.graph_objs.figure_factory.FigureFactory.create_streamline,
164+
self.assertRaises(ValueError, FigureFactory.create_streamline,
165165
**kwargs)
166166

167167
def test_wrong_density(self):
@@ -172,7 +172,7 @@ def test_wrong_density(self):
172172
'u': [[-1, -5], [-1, -5]],
173173
'v': [[1, 1], [-3, -3]],
174174
'density': 0}
175-
self.assertRaises(ValueError, plotly.graph_objs.figure_factory.FigureFactory.create_streamline,
175+
self.assertRaises(ValueError, FigureFactory.create_streamline,
176176
**kwargs)
177177

178178
def test_uneven_x(self):
@@ -182,7 +182,7 @@ def test_uneven_x(self):
182182
kwargs = {'x': [0, 2, 7, 9], 'y': [0, 2, 4, 6],
183183
'u': [[-1, -5], [-1, -5]],
184184
'v': [[1, 1], [-3, -3]]}
185-
self.assertRaises(PlotlyError, plotly.graph_objs.figure_factory.FigureFactory.create_streamline,
185+
self.assertRaises(PlotlyError, FigureFactory.create_streamline,
186186
**kwargs)
187187

188188
def test_uneven_y(self):
@@ -192,7 +192,7 @@ def test_uneven_y(self):
192192
kwargs = {'x': [0, 2, 4, 6], 'y': [1.5, 2, 3, 3.5],
193193
'u': [[-1, -5], [-1, -5]],
194194
'v': [[1, 1], [-3, -3]]}
195-
self.assertRaises(PlotlyError, plotly.graph_objs.figure_factory.FigureFactory.create_streamline,
195+
self.assertRaises(PlotlyError, FigureFactory.create_streamline,
196196
**kwargs)
197197

198198
def test_unequal_length_xy(self):
@@ -202,7 +202,7 @@ def test_unequal_length_xy(self):
202202
kwargs = {'x': [0, 2, 4, 6], 'y': [1.5, 2, 3.5],
203203
'u': [[-1, -5], [-1, -5]],
204204
'v': [[1, 1], [-3, -3]]}
205-
self.assertRaises(PlotlyError, plotly.graph_objs.figure_factory.FigureFactory.create_streamline,
205+
self.assertRaises(PlotlyError, FigureFactory.create_streamline,
206206
**kwargs)
207207

208208
def test_unequal_length_uv(self):
@@ -212,7 +212,7 @@ def test_unequal_length_uv(self):
212212
kwargs = {'x': [0, 2, 4, 6], 'y': [1.5, 2, 3, 3.5],
213213
'u': [[-1, -5], [-1, -5], [-1, -5]],
214214
'v': [[1, 1], [-3, -3]]}
215-
self.assertRaises(PlotlyError, plotly.graph_objs.figure_factory.FigureFactory.create_streamline,
215+
self.assertRaises(PlotlyError, FigureFactory.create_streamline,
216216
**kwargs)
217217

218218
def test_simple_streamline(self):
@@ -228,14 +228,14 @@ def test_simple_streamline(self):
228228
# u = u.T #transpose
229229
# v = v.T #transpose
230230

231-
strln = plotly.graph_objs.figure_factory.FigureFactory.create_streamline(x=[-1., 0., 1.],
232-
y=[-1., 0., 1.],
233-
u=[[1., 0., 1.],
234-
[1., 0., 1.],
235-
[1., 0., 1.]],
236-
v=[[1., 1., 1.],
237-
[0., 0., 0.],
238-
[1., 1., 1.]])
231+
strln = FigureFactory.create_streamline(x=[-1., 0., 1.],
232+
y=[-1., 0., 1.],
233+
u=[[1., 0., 1.],
234+
[1., 0., 1.],
235+
[1., 0., 1.]],
236+
v=[[1., 1., 1.],
237+
[0., 0., 0.],
238+
[1., 1., 1.]])
239239
expected_strln_0_100 = {
240240
'y': [-1.0, -0.9788791845863757, -0.9579399744939614, -0.9371777642073374, -0.9165881396413338, -0.8961668671832106, -0.8759098835283448, -0.8558132862403048, -0.835873324973195, -0.8160863933003534, -0.7964490210989816, -0.7769578674451656, -0.7576097139780906, -0.7384014586961288, -0.7193301101509343, -0.7003927820087748, -0.681586687951103, -0.6629091368888596, -0.64435752846723, -0.6259293488396024, -0.6076221666912738, -0.5894336294951057, -0.5713614599827976, -0.5534034528167977, -0.5355574714490806, -0.5178214451541254, -0.5001933662244311, -0.4826712873178177, -0.4652533189465894, -0.44793762709939944, -0.4307224309873414, -0.4136060009064273, -0.39658665620919065, -0.3796627633786812, -0.3628327341986042, -0.34609502401380254, -0.3294481300756896, -0.31289058996761565, -0.2964209801054992, -0.28003791430937197, -0.2637400424417804, -0.24752604910925968, -0.23139465242334434, -0.21534460281781365, -0.19937468191908325, -0.18348370146685278, -0.1676705022823033, -0.15193395328130999, -0.13627295053029143, -0.1206864163424669, -0.10517329841242584, -0.08973256898704507, -0.07436322407090357, -0.05906428266445696, -0.04383478603333624, -0.028673797007230273, -0.013580399306900914, 0.0014484211645073852, 0.01648792568956914, 0.03159429687713278, 0.04676843461935776, 0.062011259175942746, 0.07732371182540754, 0.09270675554339824, 0.10816137570939799, 0.12368858084331191, 0.1392894033734846, 0.1549649004378033, 0.1707161547196483, 0.1865442753205595, 0.20245039867161063, 0.21843568948560943, 0.23450134175238246, 0.25064857977955146, 0.26687865928136767, 0.2831928685183458, 0.29959252949062387, 0.3160789991881776, 0.33265367090123643, 0.3493179755944802, 0.366073383348855, 0.3829214048751186, 0.39986359310352526, 0.41690154485438513, 0.4340369025945845, 0.4512713562855355, 0.46860664532844054, 0.4860445606132082, 0.5035869466778524, 0.5212357039857456, 0.5389927913286829, 0.5568602283643591, 0.5748400982975623, 0.5929345507151613, 0.6111458045858065, 0.6294761514361948, 0.6479279587167714, 0.6665036733708583, 0.6852058256224467, 0.704037032999252],
241241
'x': [-1.0, -0.9788791845863756, -0.9579399744939614, -0.9371777642073374, -0.9165881396413338, -0.8961668671832106, -0.8759098835283448, -0.8558132862403048, -0.835873324973195, -0.8160863933003534, -0.7964490210989816, -0.7769578674451656, -0.7576097139780906, -0.7384014586961289, -0.7193301101509344, -0.7003927820087748, -0.6815866879511031, -0.6629091368888596, -0.6443575284672302, -0.6259293488396025, -0.6076221666912739, -0.5894336294951058, -0.5713614599827976, -0.5534034528167978, -0.5355574714490807, -0.5178214451541254, -0.5001933662244312, -0.4826712873178177, -0.4652533189465894, -0.44793762709939944, -0.4307224309873414, -0.4136060009064273, -0.39658665620919065, -0.3796627633786812, -0.3628327341986042, -0.34609502401380254, -0.3294481300756896, -0.31289058996761565, -0.2964209801054992, -0.28003791430937197, -0.2637400424417804, -0.24752604910925968, -0.23139465242334434, -0.21534460281781365, -0.19937468191908325, -0.18348370146685278, -0.1676705022823033, -0.15193395328130999, -0.13627295053029143, -0.1206864163424669, -0.10517329841242584, -0.08973256898704507, -0.07436322407090357, -0.05906428266445696, -0.04383478603333624, -0.028673797007230273, -0.013580399306900914, 0.0014484211645073852, 0.01648792568956914, 0.03159429687713278, 0.04676843461935776, 0.062011259175942746, 0.07732371182540754, 0.09270675554339824, 0.10816137570939799, 0.12368858084331191, 0.1392894033734846, 0.1549649004378033, 0.1707161547196483, 0.1865442753205595, 0.20245039867161063, 0.21843568948560943, 0.23450134175238246, 0.25064857977955146, 0.26687865928136767, 0.2831928685183458, 0.29959252949062387, 0.3160789991881776, 0.33265367090123643, 0.3493179755944802, 0.366073383348855, 0.3829214048751186, 0.39986359310352526, 0.41690154485438513, 0.4340369025945845, 0.4512713562855355, 0.46860664532844054, 0.4860445606132082, 0.5035869466778524, 0.5212357039857456, 0.5389927913286829, 0.5568602283643591, 0.5748400982975623, 0.5929345507151613, 0.6111458045858065, 0.6294761514361948, 0.6479279587167714, 0.6665036733708583, 0.6852058256224467, 0.704037032999252],
@@ -252,7 +252,7 @@ class TestDendrogram(NumpyTestUtilsMixin, TestCase):
252252

253253
def test_default_dendrogram(self):
254254
X = np.array([[1, 2, 3, 4], [1, 1, 3, 4], [1, 2, 1, 4], [1, 2, 3, 1]])
255-
dendro = plotly.graph_objs.figure_factory.FigureFactory.create_dendrogram(X=X)
255+
dendro = FigureFactory.create_dendrogram(X=X)
256256

257257
expected_dendro = go.Figure(
258258
data=go.Data([
@@ -331,7 +331,7 @@ def test_dendrogram_random_matrix(self):
331331
X[2, :] = sum(X, 0)
332332

333333
names = ['Jack', 'Oxana', 'John', 'Chelsea', 'Mark']
334-
dendro = plotly.graph_objs.figure_factory.FigureFactory.create_dendrogram(X, labels=names)
334+
dendro = FigureFactory.create_dendrogram(X, labels=names)
335335

336336
expected_dendro = go.Figure(
337337
data=go.Data([
@@ -425,26 +425,26 @@ def test_dendrogram_random_matrix(self):
425425
def test_dendrogram_orientation(self):
426426
X = np.random.rand(5, 5)
427427

428-
dendro_left = plotly.graph_objs.figure_factory.FigureFactory.create_dendrogram(
428+
dendro_left = FigureFactory.create_dendrogram(
429429
X, orientation='left')
430430
self.assertEqual(len(dendro_left['layout']['yaxis']['ticktext']), 5)
431431
tickvals_left = np.array(dendro_left['layout']['yaxis']['tickvals'])
432432
self.assertTrue((tickvals_left <= 0).all())
433433

434-
dendro_right = plotly.graph_objs.figure_factory.FigureFactory.create_dendrogram(
434+
dendro_right = FigureFactory.create_dendrogram(
435435
X, orientation='right')
436436
tickvals_right = np.array(dendro_right['layout']['yaxis']['tickvals'])
437437
self.assertTrue((tickvals_right >= 0).all())
438438

439-
dendro_bottom = plotly.graph_objs.figure_factory.FigureFactory.create_dendrogram(
439+
dendro_bottom = FigureFactory.create_dendrogram(
440440
X, orientation='bottom')
441441
self.assertEqual(len(dendro_bottom['layout']['xaxis']['ticktext']), 5)
442442
tickvals_bottom = np.array(
443443
dendro_bottom['layout']['xaxis']['tickvals']
444444
)
445445
self.assertTrue((tickvals_bottom >= 0).all())
446446

447-
dendro_top = plotly.graph_objs.figure_factory.FigureFactory.create_dendrogram(X, orientation='top')
447+
dendro_top = FigureFactory.create_dendrogram(X, orientation='top')
448448
tickvals_top = np.array(dendro_top['layout']['xaxis']['tickvals'])
449449
self.assertTrue((tickvals_top <= 0).all())
450450

@@ -463,7 +463,7 @@ def test_dendrogram_colorscale(self):
463463
'rgb(220,220,220)', # gainsboro
464464
'rgb(245,245,245)'] # white smoke
465465

466-
dendro = plotly.graph_objs.figure_factory.FigureFactory.create_dendrogram(X, colorscale=greyscale)
466+
dendro = FigureFactory.create_dendrogram(X, colorscale=greyscale)
467467

468468
expected_dendro = go.Figure(
469469
data=go.Data([

0 commit comments

Comments
 (0)