Skip to content

Commit f08b712

Browse files
committed
more explicit dates argument check
so that you can pass in `dates=df.index` and nothing will fail with the `datetimeindex isn’t a bool`
1 parent f880a5e commit f08b712

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

plotly/tools.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ def create_ohlc(open, high, low, close,
23552355
py.iplot(fig, filename='finance/simple-ohlc', validate=False)
23562356
```
23572357
"""
2358-
if dates:
2358+
if dates is not None:
23592359
TraceFactory.validate_equal_length(open, high, low, close, dates)
23602360
else:
23612361
TraceFactory.validate_equal_length(open, high, low, close)
@@ -2628,7 +2628,7 @@ def create_candlestick(open, high, low, close,
26282628
"""
26292629
FigureFactory.validate_ohlc(open, high, low, close, direction,
26302630
**kwargs)
2631-
if dates:
2631+
if dates is not None:
26322632
TraceFactory.validate_equal_length(open, high, low, close, dates)
26332633
else:
26342634
TraceFactory.validate_equal_length(open, high, low, close)
@@ -2683,10 +2683,8 @@ def __init__(self, open, high, low, close, dates, **kwargs):
26832683
self.low = low
26842684
self.close = close
26852685
self.empty = [None] * len(open)
2686-
if dates:
2687-
self.dates = dates
2688-
else:
2689-
self.dates = None
2686+
self.dates = dates
2687+
26902688
self.all_x = []
26912689
self.all_y = []
26922690
self.increase_x = []
@@ -2709,7 +2707,7 @@ def get_all_xy(self):
27092707
"""
27102708
self.all_y = list(zip(self.open, self.open, self.high,
27112709
self.low, self.close, self.close, self.empty))
2712-
if self.dates:
2710+
if self.dates is not None:
27132711
date_dif = []
27142712
for i in range(len(self.dates) - 1):
27152713
date_dif.append(self.dates[i + 1] - self.dates[i])
@@ -2780,7 +2778,7 @@ def __init__(self, open, high, low, close, dates, **kwargs):
27802778
self.high = high
27812779
self.low = low
27822780
self.close = close
2783-
if dates:
2781+
if dates is not None:
27842782
self.x = dates
27852783
else:
27862784
self.x = [x for x in range(len(self.open))]

0 commit comments

Comments
 (0)