Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 18ad118

Browse files
committed
distplot_updates
- hide validate functions from tab-tab helper - add pandas example and pandas type to validation - replace `**kwargs` with `rug_text` and `colors` in - updated the docstring with Andrew’s nice terse suggestions - hid tick label from rug plot - modified rug_text so its indexed across datasets, not copied - edited examples - added import numpy where needed - increased sample sizes - reversed legend - fix the show_legend issue so a legend is shown if the hist is hidden - add test to test_core to check exception for `scipy_import = False` - edit tests in test optional to reflect the changes (mentioned above) made
1 parent 2c5ab6c commit 18ad118

File tree

3 files changed

+151
-95
lines changed

3 files changed

+151
-95
lines changed

‎plotly/tests/test_core/test_tools/test_figure_factory.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,3 +802,22 @@ def test_datetime_candlestick(self):
802802

803803
self.assertEqual(candle, exp_candle)
804804

805+
806+
class TestDistplot(TestCase):
807+
808+
def test_scipy_import_error(self):
809+
810+
# make sure Import Error is raised when _scipy_imported = False
811+
812+
hist_data = [[1.1, 1.1, 2.5, 3.0, 3.5,
813+
3.5, 4.1, 4.4, 4.5, 4.5,
814+
5.0, 5.0, 5.2, 5.5, 5.5,
815+
5.5, 5.5, 5.5, 6.1, 7.0]]
816+
817+
group_labels = ['distplot example']
818+
819+
self.assertRaisesRegexp(ImportError,
820+
"FigureFactory.create_distplot requires scipy",
821+
tls.FigureFactory.create_distplot,
822+
hist_data, group_labels)
823+

‎plotly/tests/test_optional/test_opt_tracefactory.py‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ def test_simple_distplot(self):
4949
dp = tls.FigureFactory.create_distplot(hist_data=[[1, 2, 2, 3]],
5050
group_labels=['distplot'])
5151
expected_dp_layout = {'barmode': 'overlay',
52-
'hovermode': 'closest',
53-
'xaxis1': {'anchor': 'y2',
54-
'domain': [0.0, 1.0],
55-
'zeroline': False},
56-
'yaxis1': {'anchor': 'free',
57-
'domain': [0.35, 1],
58-
'position': 0.0},
59-
'yaxis2': {'anchor': 'x1',
60-
'domain': [0, 0.25],
61-
'dtick': 1}}
52+
'hovermode': 'closest',
53+
'legend': {'traceorder': 'reversed'},
54+
'xaxis1': {'anchor': 'y2', 'domain': [0.0, 1.0], 'zeroline': False},
55+
'yaxis1': {'anchor': 'free', 'domain': [0.35, 1], 'position': 0.0},
56+
'yaxis2': {'anchor': 'x1',
57+
'domain': [0, 0.25],
58+
'dtick': 1,
59+
'showticklabels': False}}
6260
self.assertEqual(dp['layout'], expected_dp_layout)
6361

6462
expected_dp_data_hist = {'autobinx': False,
@@ -70,8 +68,7 @@ def test_simple_distplot(self):
7068
'type': 'histogram',
7169
'x': [1, 2, 2, 3],
7270
'xaxis': 'x1',
73-
'xbins': {'end': 3.0, 'size': 1.0,
74-
'start': 1.0},
71+
'xbins': {'end': 3.0, 'size': 1.0, 'start': 1.0},
7572
'yaxis': 'y1'}
7673
self.assertEqual(dp['data'][0], expected_dp_data_hist)
7774

@@ -85,8 +82,8 @@ def test_simple_distplot(self):
8582
'type': 'scatter',
8683
'x': [1, 2, 2, 3],
8784
'xaxis': 'x1',
88-
'y': ['distplot', 'distplot','distplot',
89-
'distplot'],
85+
'y': ['distplot', 'distplot',
86+
'distplot', 'distplot'],
9087
'yaxis': 'y2'}
9188
self.assertEqual(dp['data'][2], expected_dp_data_rug)
9289

@@ -111,6 +108,7 @@ def test_distplot_more_args(self):
111108

112109
expected_dp_layout = {'barmode': 'overlay',
113110
'hovermode': 'closest',
111+
'legend': {'traceorder': 'reversed'},
114112
'title': 'Dist Plot',
115113
'xaxis1': {'anchor': 'y2', 'domain': [0.0, 1.0],
116114
'zeroline': False},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /