@@ -1516,21 +1516,17 @@ def validate_distplot(hist_data, curve_type):
1516
1516
:raises: (PlotlyError) If curve_type is not valid (i.e. not 'kde' or
1517
1517
'normal').
1518
1518
"""
1519
- if _numpy_imported is True :
1520
- if type (hist_data [0 ]) not in [list , np .ndarray ]:
1519
+ hist_data_types = (list ,)
1520
+ if _numpy_imported :
1521
+ hist_data_types += (np .ndarray ,)
1522
+
1523
+ if not isinstance (hist_data [0 ], hist_data_types ):
1521
1524
raise exceptions .PlotlyError ("Oops, this function was written "
1522
1525
"to handle multiple datasets, if "
1523
1526
"you want to plot just one, make "
1524
1527
"sure your hist_data variable is "
1525
1528
"still a list of lists, i.e. x = "
1526
1529
"[1, 2, 3] -> x = [[1, 2, 3]]" )
1527
- elif type (hist_data [0 ]) is not list :
1528
- raise exceptions .PlotlyError ("Oops, this function was written "
1529
- "to handle multiple datasets, if "
1530
- "you want to plot just one, make "
1531
- "sure your hist_data variable is "
1532
- "still a list of lists, i.e. x = "
1533
- "[1, 2, 3] -> x = [[1, 2, 3]]" )
1534
1530
1535
1531
curve_opts = ('kde' , 'normal' )
1536
1532
if curve_type not in curve_opts :
@@ -2453,15 +2449,15 @@ def create_distplot(hist_data, group_labels,
2453
2449
anchor = 'x1' ,
2454
2450
dtick = 1 ))
2455
2451
else :
2456
- layout = graph_objs .Layout (
2457
- barmode = 'overlay' ,
2458
- hovermode = 'closest' ,
2459
- xaxis1 = dict (domain = [0.0 , 1.0 ],
2460
- anchor = 'y2' ,
2461
- zeroline = False ),
2462
- yaxis1 = dict (domain = [0. , 1 ],
2463
- anchor = 'free' ,
2464
- position = 0.0 ))
2452
+ layout = graph_objs .Layout (
2453
+ barmode = 'overlay' ,
2454
+ hovermode = 'closest' ,
2455
+ xaxis1 = dict (domain = [0.0 , 1.0 ],
2456
+ anchor = 'y2' ,
2457
+ zeroline = False ),
2458
+ yaxis1 = dict (domain = [0. , 1 ],
2459
+ anchor = 'free' ,
2460
+ position = 0.0 ))
2465
2461
2466
2462
data = sum (data , [])
2467
2463
dist_fig = dict (data = data , layout = layout )
0 commit comments