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)
| 14 | |
| 15 | |
| 16 | def 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 | |
| 48 | def create_distplot( |