Skip to content

Commit 4bb9482

Browse files
committed
added test for the binsize array input
1 parent 77086f5 commit 4bb9482

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

plotly/tests/test_optional/test_figure_factory.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,53 @@ def test_distplot_more_args(self):
149149
'yaxis': 'y1'}
150150
self.assertEqual(dp['data'][1], expected_dp_data_hist_2)
151151

152+
def test_distplot_binsize_array(self):
153+
hist1_x = [0.8, 1.2, 0.2, 0.6, 1.6,
154+
-0.9, -0.07, 1.95, 0.9, -0.2,
155+
-0.5, 0.3, 0.4, -0.37, 0.6]
156+
hist2_x = [0.8, 1.5, 1.5, 0.6, 0.59,
157+
1.0, 0.8, 1.7, 0.5, 0.8,
158+
-0.3, 1.2, 0.56, 0.3, 2.2]
159+
160+
hist_data = [hist1_x] + [hist2_x]
161+
group_labels = ['2012', '2013']
162+
163+
dp = tls.FigureFactory.create_distplot(hist_data, group_labels,
164+
show_rug=False,
165+
bin_size=[.2, .2])
166+
167+
expected_dp_data_hist_1 = {'autobinx': False,
168+
'histnorm': 'probability',
169+
'legendgroup': '2012',
170+
'marker': {'color': 'rgb(31, 119, 180)'},
171+
'name': '2012',
172+
'opacity': 0.7,
173+
'type': 'histogram',
174+
'x': [0.8, 1.2, 0.2, 0.6, 1.6, -0.9, -0.07,
175+
1.95, 0.9, -0.2, -0.5, 0.3, 0.4,
176+
-0.37, 0.6],
177+
'xaxis': 'x1',
178+
'xbins': {'end': 1.95, 'size': 0.2,
179+
'start': -0.9},
180+
'yaxis': 'y1'}
181+
self.assertEqual(dp['data'][0], expected_dp_data_hist_1)
182+
183+
expected_dp_data_hist_2 = {'autobinx': False,
184+
'histnorm': 'probability',
185+
'legendgroup': '2013',
186+
'marker': {'color': 'rgb(255, 127, 14)'},
187+
'name': '2013',
188+
'opacity': 0.7,
189+
'type': 'histogram',
190+
'x': [0.8, 1.5, 1.5, 0.6, 0.59, 1.0, 0.8,
191+
1.7, 0.5, 0.8, -0.3, 1.2, 0.56, 0.3,
192+
2.2],
193+
'xaxis': 'x1',
194+
'xbins': {'end': 2.2, 'size': 0.2,
195+
'start': -0.3},
196+
'yaxis': 'y1'}
197+
self.assertEqual(dp['data'][1], expected_dp_data_hist_2)
198+
152199

153200
class TestStreamline(TestCase):
154201

@@ -422,7 +469,7 @@ def test_dendrogram_random_matrix(self):
422469
self.assert_dict_equal(dendro['layout'], expected_dendro['layout'])
423470

424471
def test_dendrogram_orientation(self):
425-
X = np.random.rand(5, 5)
472+
X = np.random.rand(5, 5)
426473

427474
dendro_left = tls.FigureFactory.create_dendrogram(
428475
X, orientation='left')

0 commit comments

Comments
 (0)