Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 647a3d3

Browse files
committed
More pep:8ball:
* line too long * bad line breaking at operators (e.g., `*`) * continuation line over-intented
1 parent 76d3ba2 commit 647a3d3

File tree

1 file changed

+54
-37
lines changed

1 file changed

+54
-37
lines changed

plotly/graph_objs/figure_factory.py

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,10 @@ def create_ohlc(open, high, low, close,
511511
512512
import pandas.io.data as web
513513
514-
df = web.DataReader("aapl", 'yahoo', datetime(2008, 8, 15), datetime(2008, 10, 15))
515-
fig = FF.create_ohlc(df.Open, df.High, df.Low, df.Close, dates=df.index)
514+
df = web.DataReader("aapl", 'yahoo', datetime(2008, 8, 15),
515+
datetime(2008, 10, 15))
516+
fig = FF.create_ohlc(df.Open, df.High, df.Low, df.Close,
517+
dates=df.index)
516518
517519
py.plot(fig, filename='finance/aapl-ohlc')
518520
```
@@ -525,10 +527,12 @@ def create_ohlc(open, high, low, close,
525527
526528
import pandas.io.data as web
527529
528-
df = web.DataReader("aapl", 'yahoo', datetime(2008, 8, 15), datetime(2008, 10, 15))
529-
fig = FF.create_ohlc(df.Open, df.High, df.Low, df.Close, dates=df.index)
530+
df = web.DataReader("aapl", 'yahoo', datetime(2008, 8, 15),
531+
datetime(2008, 10, 15))
532+
fig = FF.create_ohlc(df.Open, df.High, df.Low, df.Close,
533+
dates=df.index)
530534
531-
# Update the fig - all options here: https://plot.ly/python/reference/#Layout
535+
# Update the fig - See https://plot.ly/python/reference/#Layout
532536
fig['layout'].update({
533537
'title': 'The Great Recession',
534538
'yaxis': {'title': 'AAPL Stock'},
@@ -557,17 +561,20 @@ def create_ohlc(open, high, low, close,
557561
558562
import pandas.io.data as web
559563
560-
df = web.DataReader("aapl", 'yahoo', datetime(2008, 1, 1), datetime(2009, 4, 1))
564+
df = web.DataReader("aapl", 'yahoo', datetime(2008, 1, 1),
565+
datetime(2009, 4, 1))
561566
562567
# Make increasing ohlc sticks and customize their color and name
563-
fig_increasing = FF.create_ohlc(df.Open, df.High, df.Low, df.Close, dates=df.index,
568+
fig_increasing = FF.create_ohlc(df.Open, df.High, df.Low, df.Close,
569+
dates=df.index,
564570
direction='increasing', name='AAPL',
565571
line=Line(color='rgb(150, 200, 250)'))
566572
567573
# Make decreasing ohlc sticks and customize their color and name
568-
fig_decreasing = FF.create_ohlc(df.Open, df.High, df.Low, df.Close, dates=df.index,
569-
direction='decreasing',
570-
line=Line(color='rgb(128, 128, 128)'))
574+
fig_decreasing = FF.create_ohlc(df.Open, df.High, df.Low, df.Close,
575+
dates=df.index,
576+
direction='decreasing',
577+
line=Line(color='rgb(128, 128, 128)'))
571578
572579
# Initialize the figure
573580
fig = fig_increasing
@@ -608,7 +615,7 @@ def create_ohlc(open, high, low, close,
608615
else:
609616
FigureFactory._validate_equal_length(open, high, low, close)
610617
FigureFactory._validate_ohlc(open, high, low, close, direction,
611-
**kwargs)
618+
**kwargs)
612619

613620
if direction is 'increasing':
614621
ohlc_incr = FigureFactory._make_increasing_ohlc(open, high,
@@ -750,15 +757,18 @@ def create_candlestick(open, high, low, close,
750757
751758
import pandas.io.data as web
752759
753-
df = web.DataReader("aapl", 'yahoo', datetime(2007, 10, 1), datetime(2009, 4, 1))
754-
fig = FF.create_candlestick(df.Open, df.High, df.Low, df.Close, dates=df.index)
760+
df = web.DataReader("aapl", 'yahoo', datetime(2007, 10, 1),
761+
datetime(2009, 4, 1))
762+
fig = FF.create_candlestick(df.Open, df.High, df.Low, df.Close,
763+
dates=df.index)
755764
py.plot(fig, filename='finance/aapl-candlestick', validate=False)
756765
```
757766
758767
Example 2: Add text and annotations to the candlestick chart
759768
```
760-
fig = FF.create_candlestick(df.Open, df.High, df.Low, df.Close, dates=df.index)
761-
# Update the fig - all options here: https://plot.ly/python/reference/#Layout
769+
fig = FF.create_candlestick(df.Open, df.High, df.Low, df.Close,
770+
dates=df.index)
771+
# Update the fig - See https://plot.ly/python/reference/#Layout
762772
fig['layout'].update({
763773
'title': 'The Great Recession',
764774
'yaxis': {'title': 'AAPL Stock'},
@@ -773,7 +783,8 @@ def create_candlestick(open, high, low, close,
773783
'text': 'Official start of the recession'
774784
}]
775785
})
776-
py.plot(fig, filename='finance/aapl-recession-candlestick', validate=False)
786+
py.plot(fig, filename='finance/aapl-recession-candlestick',
787+
validate=False)
777788
```
778789
779790
Example 3: Customize the candlestick colors
@@ -785,27 +796,32 @@ def create_candlestick(open, high, low, close,
785796
786797
import pandas.io.data as web
787798
788-
df = web.DataReader("aapl", 'yahoo', datetime(2008, 1, 1), datetime(2009, 4, 1))
799+
df = web.DataReader("aapl", 'yahoo', datetime(2008, 1, 1),
800+
datetime(2009, 4, 1))
789801
790802
# Make increasing candlesticks and customize their color and name
791-
fig_increasing = FF.create_candlestick(df.Open, df.High, df.Low, df.Close, dates=df.index,
803+
fig_increasing = FF.create_candlestick(
804+
df.Open, df.High, df.Low, df.Close, dates=df.index,
792805
direction='increasing', name='AAPL',
793806
marker=Marker(color='rgb(150, 200, 250)'),
794-
line=Line(color='rgb(150, 200, 250)'))
807+
line=Line(color='rgb(150, 200, 250)')
808+
)
795809
796810
# Make decreasing candlesticks and customize their color and name
797-
fig_decreasing = FF.create_candlestick(df.Open, df.High, df.Low, df.Close, dates=df.index,
798-
direction='decreasing',
799-
marker=Marker(color='rgb(128, 128, 128)'),
800-
line=Line(color='rgb(128, 128, 128)'))
811+
fig_decreasing = FF.create_candlestick(
812+
df.Open, df.High, df.Low, df.Close, dates=df.index,
813+
direction='decreasing', marker=Marker(color='rgb(128, 128, 128)'),
814+
line=Line(color='rgb(128, 128, 128)')
815+
)
801816
802817
# Initialize the figure
803818
fig = fig_increasing
804819
805820
# Add decreasing data with .extend()
806821
fig['data'].extend(fig_decreasing['data'])
807822
808-
py.iplot(fig, filename='finance/aapl-candlestick-custom', validate=False)
823+
py.iplot(fig, filename='finance/aapl-candlestick-custom',
824+
validate=False)
809825
```
810826
811827
Example 4: Candlestick chart with datetime objects
@@ -838,7 +854,7 @@ def create_candlestick(open, high, low, close,
838854
else:
839855
FigureFactory._validate_equal_length(open, high, low, close)
840856
FigureFactory._validate_ohlc(open, high, low, close, direction,
841-
**kwargs)
857+
**kwargs)
842858

843859
if direction is 'increasing':
844860
candle_incr_data = FigureFactory._make_increasing_candle(
@@ -1075,8 +1091,8 @@ def create_dendrogram(X, orientation="bottom", labels=None,
10751091
_scipy__cluster__hierarchy_imported)
10761092

10771093
if dependencies is False:
1078-
raise ImportError("FigureFactory.create_dendrogram requires scipy, \
1079-
scipy.spatial and scipy.hierarchy")
1094+
raise ImportError("FigureFactory.create_dendrogram requires "
1095+
"scipy, scipy.spatial and scipy.hierarchy")
10801096

10811097
s = X.shape
10821098
if len(s) != 2:
@@ -1317,8 +1333,9 @@ def g(xi, yi):
13171333
vi = self.value_at(self.v, xi, yi)
13181334
return -ui * dt_ds, -vi * dt_ds
13191335

1320-
check = lambda xi, yi: (0 <= xi < len(self.x) - 1 and
1321-
0 <= yi < len(self.y) - 1)
1336+
def check(xi, yi):
1337+
return 0 <= xi < len(self.x) - 1 and 0 <= yi < len(self.y) - 1
1338+
13221339
xb_changes = []
13231340
yb_changes = []
13241341

@@ -1579,8 +1596,8 @@ def get_increase(self):
15791596
flat_increase_x = FigureFactory._flatten(self.increase_x)
15801597
flat_increase_y = FigureFactory._flatten(self.increase_y)
15811598
text_increase = (("Open", "Open", "High",
1582-
"Low", "Close", "Close", '')
1583-
* (len(self.increase_x)))
1599+
"Low", "Close", "Close", '') *
1600+
(len(self.increase_x)))
15841601

15851602
return flat_increase_x, flat_increase_y, text_increase
15861603

@@ -1595,8 +1612,8 @@ def get_decrease(self):
15951612
flat_decrease_x = FigureFactory._flatten(self.decrease_x)
15961613
flat_decrease_y = FigureFactory._flatten(self.decrease_y)
15971614
text_decrease = (("Open", "Open", "High",
1598-
"Low", "Close", "Close", '')
1599-
* (len(self.decrease_x)))
1615+
"Low", "Close", "Close", '') *
1616+
(len(self.decrease_x)))
16001617

16011618
return flat_decrease_x, flat_decrease_y, text_decrease
16021619

@@ -1736,8 +1753,8 @@ def make_kde(self):
17361753
curve = [None] * self.trace_number
17371754
for index in range(self.trace_number):
17381755
self.curve_x[index] = [self.start[index] +
1739-
x * (self.end[index] - self.start[index])
1740-
/ 500 for x in range(500)]
1756+
x * (self.end[index] - self.start[index]) /
1757+
500 for x in range(500)]
17411758
self.curve_y[index] = (scipy.stats.gaussian_kde
17421759
(self.hist_data[index])
17431760
(self.curve_x[index]))
@@ -1772,8 +1789,8 @@ def make_normal(self):
17721789
mean[index], sd[index] = (scipy.stats.norm.fit
17731790
(self.hist_data[index]))
17741791
self.curve_x[index] = [self.start[index] +
1775-
x * (self.end[index] - self.start[index])
1776-
/ 500 for x in range(500)]
1792+
x * (self.end[index] - self.start[index]) /
1793+
500 for x in range(500)]
17771794
self.curve_y[index] = scipy.stats.norm.pdf(
17781795
self.curve_x[index], loc=mean[index], scale=sd[index])
17791796
self.curve_y[index] *= self.bin_size

0 commit comments

Comments
 (0)