MCPcopy Index your code
hub / github.com/plotly/plotly.py / validate_distplot

Function validate_distplot

plotly/figure_factory/_distplot.py:16–45  ·  view source on GitHub ↗

Distplot-specific validations :raises: (PlotlyError) If hist_data is not a list of lists :raises: (PlotlyError) If curve_type is not valid (i.e. not 'kde' or 'normal').

(hist_data, curve_type)

Source from the content-addressed store, hash-verified

14
15
16def validate_distplot(hist_data, curve_type):
17 """
18 Distplot-specific validations
19
20 :raises: (PlotlyError) If hist_data is not a list of lists
21 :raises: (PlotlyError) If curve_type is not valid (i.e. not 'kde' or
22 'normal').
23 """
24 hist_data_types = (list,)
25 if np:
26 hist_data_types += (np.ndarray,)
27 if pd:
28 hist_data_types += (pd.core.series.Series,)
29
30 if not isinstance(hist_data[0], hist_data_types):
31 raise exceptions.PlotlyError(
32 "Oops, this function was written "
33 "to handle multiple datasets, if "
34 "you want to plot just one, make "
35 "sure your hist_data variable is "
36 "still a list of lists, i.e. x = "
37 "[1, 2, 3] -> x = [[1, 2, 3]]"
38 )
39
40 curve_opts = ("kde", "normal")
41 if curve_type not in curve_opts:
42 raise exceptions.PlotlyError("curve_type must be defined as 'kde' or 'normal'")
43
44 if not scipy:
45 raise ImportError("FigureFactory.create_distplot requires scipy")
46
47
48def create_distplot(

Callers 1

create_distplotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected