Skip to content

Commit 08c0cc1

Browse files
committed
Ignore flake8 warnings in intro-to-bokeh code snippets
1 parent 1ba7f31 commit 08c0cc1

22 files changed

+521
-356
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
"""Bokeh Visualization Template
22
3-
This template is a general outline for turning your data into a
3+
This template is a general outline for turning your data into a
44
visualization using Bokeh.
55
"""
66
# Data handling
7-
import pandas as pd
8-
import numpy as np
7+
import pandas as pd # noqa
8+
import numpy as np # noqa
99

1010
# Bokeh libraries
1111
from bokeh.io import output_file, output_notebook
1212
from bokeh.plotting import figure, show
13-
from bokeh.models import ColumnDataSource
14-
from bokeh.layouts import row, column, gridplot
15-
from bokeh.models.widgets import Tabs, Panel
13+
from bokeh.models import ColumnDataSource # noqa
14+
from bokeh.layouts import row, column, gridplot # noqa
15+
from bokeh.models.widgets import Tabs, Panel # noqa
1616

1717
# Prepare the data
1818

1919
# Determine where the visualization will be rendered
20-
output_file('filename.html') # Render to static HTML, or
20+
output_file("filename.html") # Render to static HTML, or
2121
output_notebook() # Render inline in a Jupyter Notebook
2222

2323
# Set up the figure(s)
@@ -27,5 +27,5 @@
2727

2828
# Organize the layout
2929

30-
# Preview and save
31-
show(fig) # See what I made, and save if I like it
30+
# Preview and save
31+
show(fig) # See what I made, and save if I like it

intro-to-bokeh/code-snippets/east-top-2-race-v0.py

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,55 @@
44
from bokeh.models import ColumnDataSource, CDSView, GroupFilter
55

66
# Output to file
7-
output_file('east-top-2-standings-race.html',
8-
title='Eastern Conference Top 2 Teams Wins Race')
7+
output_file(
8+
"east-top-2-standings-race.html",
9+
title="Eastern Conference Top 2 Teams Wins Race",
10+
)
911

1012
# Create a ColumnDataSource
11-
standings_cds = ColumnDataSource(standings)
13+
standings_cds = ColumnDataSource(standings) # noqa
1214

1315
# Create views for each team
14-
celtics_view = CDSView(source=standings_cds,
15-
filters=[GroupFilter(column_name='teamAbbr',
16-
group='BOS')])
17-
raptors_view = CDSView(source=standings_cds,
18-
filters=[GroupFilter(column_name='teamAbbr',
19-
group='TOR')])
16+
celtics_view = CDSView(
17+
source=standings_cds,
18+
filters=[GroupFilter(column_name="teamAbbr", group="BOS")],
19+
)
20+
raptors_view = CDSView(
21+
source=standings_cds,
22+
filters=[GroupFilter(column_name="teamAbbr", group="TOR")],
23+
)
2024

2125
# Create and configure the figure
22-
east_fig = figure(x_axis_type='datetime',
23-
plot_height=300, plot_width=600,
24-
title='Eastern Conference Top 2 Teams Wins Race, 2017-18',
25-
x_axis_label='Date', y_axis_label='Wins',
26-
toolbar_location=None)
26+
east_fig = figure(
27+
x_axis_type="datetime",
28+
plot_height=300,
29+
plot_width=600,
30+
title="Eastern Conference Top 2 Teams Wins Race, 2017-18",
31+
x_axis_label="Date",
32+
y_axis_label="Wins",
33+
toolbar_location=None,
34+
)
2735

2836
# Render the race as step lines
29-
east_fig.step('stDate', 'gameWon',
30-
color='#007A33', legend='Celtics',
31-
source=standings_cds, view=celtics_view)
32-
east_fig.step('stDate', 'gameWon',
33-
color='#CE1141', legend='Raptors',
34-
source=standings_cds, view=raptors_view)
37+
east_fig.step(
38+
"stDate",
39+
"gameWon",
40+
color="#007A33",
41+
legend="Celtics",
42+
source=standings_cds,
43+
view=celtics_view,
44+
)
45+
east_fig.step(
46+
"stDate",
47+
"gameWon",
48+
color="#CE1141",
49+
legend="Raptors",
50+
source=standings_cds,
51+
view=raptors_view,
52+
)
3553

3654
# Move the legend to the upper left corner
37-
east_fig.legend.location = 'top_left'
55+
east_fig.legend.location = "top_left"
3856

3957
# Show the plot
40-
show(east_fig)
58+
show(east_fig)
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Bokeh library
2-
from bokeh.plotting import figure, show
2+
from bokeh.plotting import show
33
from bokeh.io import output_file
44
from bokeh.layouts import column
55

66
# Output to file
7-
output_file('east-west-top-2-standings-race.html',
8-
title='Conference Top 2 Teams Wins Race')
7+
output_file(
8+
"east-west-top-2-standings-race.html",
9+
title="Conference Top 2 Teams Wins Race",
10+
)
911

1012
# Plot the two visualizations in a vertical configuration
11-
show(column(west_fig, east_fig))
13+
show(column(west_fig, east_fig)) # noqa

intro-to-bokeh/code-snippets/east-west-gridplot-layout-with-nones.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
from bokeh.layouts import gridplot
44

55
# Output to file
6-
output_file('east-west-top-2-gridplot.html',
7-
title='Conference Top 2 Teams Wins Race')
6+
output_file(
7+
"east-west-top-2-gridplot.html", title="Conference Top 2 Teams Wins Race"
8+
)
89

910
# Reduce the width of both figures
10-
east_fig.plot_width = west_fig.plot_width = 300
11+
east_fig.plot_width = west_fig.plot_width = 300 # noqa
1112

1213
# Edit the titles
13-
east_fig.title.text = 'Eastern Conference'
14-
west_fig.title.text = 'Western Conference'
14+
east_fig.title.text = "Eastern Conference" # noqa
15+
west_fig.title.text = "Western Conference" # noqa
1516

1617
# Plot the two visualizations with placeholders
17-
east_west_gridplot = gridplot([[west_fig, None], [None, east_fig]],
18-
toolbar_location='right')
18+
east_west_gridplot = gridplot(
19+
[[west_fig, None], [None, east_fig]], toolbar_location="right" # noqa
20+
)
1921

2022
# Plot the two visualizations in a horizontal configuration
21-
show(east_west_gridplot)
23+
show(east_west_gridplot) # noqa

intro-to-bokeh/code-snippets/east-west-gridplot-layout.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
from bokeh.layouts import gridplot
44

55
# Output to file
6-
output_file('east-west-top-2-gridplot.html',
7-
title='Conference Top 2 Teams Wins Race')
6+
output_file(
7+
"east-west-top-2-gridplot.html", title="Conference Top 2 Teams Wins Race"
8+
)
89

910
# Reduce the width of both figures
10-
east_fig.plot_width = west_fig.plot_width = 300
11+
east_fig.plot_width = west_fig.plot_width = 300 # noqa
1112

1213
# Edit the titles
13-
east_fig.title.text = 'Eastern Conference'
14-
west_fig.title.text = 'Western Conference'
14+
east_fig.title.text = "Eastern Conference" # noqa
15+
west_fig.title.text = "Western Conference" # noqa
1516

1617
# Configure the gridplot
17-
east_west_gridplot = gridplot([[west_fig, east_fig]],
18-
toolbar_location='right')
18+
east_west_gridplot = gridplot([[west_fig, east_fig]], toolbar_location="right") # noqa
1919

2020
# Plot the two visualizations in a horizontal configuration
21-
show(east_west_gridplot)
21+
show(east_west_gridplot) # noqa
Lines changed: 68 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,82 @@
11
# Bokeh libraries
2-
from bokeh.plotting import figure, show
2+
from bokeh.plotting import figure
33
from bokeh.models import ColumnDataSource, CDSView, GroupFilter
44

55
# Create a ColumnDataSource
6-
standings_cds = ColumnDataSource(standings)
6+
standings_cds = ColumnDataSource(standings) # noqa
77

88
# Create the views for each team
9-
celtics_view = CDSView(source=standings_cds,
10-
filters=[GroupFilter(column_name='teamAbbr',
11-
group='BOS')])
9+
celtics_view = CDSView(
10+
source=standings_cds,
11+
filters=[GroupFilter(column_name="teamAbbr", group="BOS")],
12+
)
1213

13-
raptors_view = CDSView(source=standings_cds,
14-
filters=[GroupFilter(column_name='teamAbbr',
15-
group='TOR')])
14+
raptors_view = CDSView(
15+
source=standings_cds,
16+
filters=[GroupFilter(column_name="teamAbbr", group="TOR")],
17+
)
1618

17-
rockets_view = CDSView(source=standings_cds,
18-
filters=[GroupFilter(column_name='teamAbbr',
19-
group='HOU')])
20-
warriors_view = CDSView(source=standings_cds,
21-
filters=[GroupFilter(column_name='teamAbbr',
22-
group='GS')])
19+
rockets_view = CDSView(
20+
source=standings_cds,
21+
filters=[GroupFilter(column_name="teamAbbr", group="HOU")],
22+
)
23+
warriors_view = CDSView(
24+
source=standings_cds,
25+
filters=[GroupFilter(column_name="teamAbbr", group="GS")],
26+
)
2327

2428
# Create and configure the figure
25-
east_fig = figure(x_axis_type='datetime',
26-
plot_height=300,
27-
x_axis_label='Date',
28-
y_axis_label='Wins',
29-
toolbar_location=None)
30-
31-
west_fig = figure(x_axis_type='datetime',
32-
plot_height=300,
33-
x_axis_label='Date',
34-
y_axis_label='Wins',
35-
toolbar_location=None)
29+
east_fig = figure(
30+
x_axis_type="datetime",
31+
plot_height=300,
32+
x_axis_label="Date",
33+
y_axis_label="Wins",
34+
toolbar_location=None,
35+
)
36+
37+
west_fig = figure(
38+
x_axis_type="datetime",
39+
plot_height=300,
40+
x_axis_label="Date",
41+
y_axis_label="Wins",
42+
toolbar_location=None,
43+
)
3644

3745
# Configure the figures for each conference
38-
east_fig.step('stDate', 'gameWon',
39-
color='#007A33', legend='Celtics',
40-
source=standings_cds, view=celtics_view)
41-
east_fig.step('stDate', 'gameWon',
42-
color='#CE1141', legend='Raptors',
43-
source=standings_cds, view=raptors_view)
44-
45-
west_fig.step('stDate', 'gameWon', color='#CE1141', legend='Rockets',
46-
source=standings_cds, view=rockets_view)
47-
west_fig.step('stDate', 'gameWon', color='#006BB6', legend='Warriors',
48-
source=standings_cds, view=warriors_view)
46+
east_fig.step(
47+
"stDate",
48+
"gameWon",
49+
color="#007A33",
50+
legend="Celtics",
51+
source=standings_cds,
52+
view=celtics_view,
53+
)
54+
east_fig.step(
55+
"stDate",
56+
"gameWon",
57+
color="#CE1141",
58+
legend="Raptors",
59+
source=standings_cds,
60+
view=raptors_view,
61+
)
62+
63+
west_fig.step(
64+
"stDate",
65+
"gameWon",
66+
color="#CE1141",
67+
legend="Rockets",
68+
source=standings_cds,
69+
view=rockets_view,
70+
)
71+
west_fig.step(
72+
"stDate",
73+
"gameWon",
74+
color="#006BB6",
75+
legend="Warriors",
76+
source=standings_cds,
77+
view=warriors_view,
78+
)
4979

5080
# Move the legend to the upper left corner
51-
east_fig.legend.location = 'top_left'
52-
west_fig.legend.location = 'top_left'
81+
east_fig.legend.location = "top_left"
82+
west_fig.legend.location = "top_left"

intro-to-bokeh/code-snippets/east-west-tabbed-layout.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
from bokeh.models.widgets import Tabs, Panel
44

55
# Output to file
6-
output_file('east-west-top-2-tabbed_layout.html',
7-
title='Conference Top 2 Teams Wins Race')
6+
output_file(
7+
"east-west-top-2-tabbed_layout.html",
8+
title="Conference Top 2 Teams Wins Race",
9+
)
810

911
# Increase the plot widths
10-
east_fig.plot_width = west_fig.plot_width = 800
12+
east_fig.plot_width = west_fig.plot_width = 800 # noqa
1113

1214
# Create two panels, one for each conference
13-
east_panel = Panel(child=east_fig, title='Eastern Conference')
14-
west_panel = Panel(child=west_fig, title='Western Conference')
15+
east_panel = Panel(child=east_fig, title="Eastern Conference") # noqa
16+
west_panel = Panel(child=west_fig, title="Western Conference") # noqa
1517

1618
# Assign the panels to Tabs
1719
tabs = Tabs(tabs=[west_panel, east_panel])
1820

1921
# Show the tabbed layout
20-
show(tabs)
22+
show(tabs) # noqa

0 commit comments

Comments
 (0)