Skip to content

Commit 68ee2bd

Browse files
run black
Former-commit-id: a89bdb9
1 parent 436d387 commit 68ee2bd

14 files changed

Lines changed: 2361 additions & 1421 deletions

File tree

apps/dash-chess-analytics/app.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,7 @@ def board_output(df, col_list):
357357

358358
dropdown_status = dbc.DropdownMenu(
359359
[
360-
dbc.DropdownMenuItem(
361-
str(
362-
"Status",
363-
).upper(),
364-
header=True,
365-
),
360+
dbc.DropdownMenuItem(str("Status",).upper(), header=True,),
366361
dbc.DropdownMenuItem(str("All").upper(), id="st_all", n_clicks=0),
367362
dbc.DropdownMenuItem(str("Draws").upper(), id="st_draw", n_clicks=0),
368363
dbc.DropdownMenuItem(str("Checkmate").upper(), id="st_mate", n_clicks=0),

apps/dash-chess-analytics/app_components.py

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -111,32 +111,58 @@ def board_output(df, col_list):
111111
}
112112

113113

114+
popover_status = dbc.Popover(
115+
[
116+
dbc.PopoverHeader("Status of the Game"),
117+
dbc.PopoverBody(
118+
"Games can be over in a myriad of ways, either by checkmate, draw, player resignation, or when a player runs out of time. Filter the games by these conditions here."
119+
),
120+
],
121+
trigger="hover",
122+
target="dropdown_status",
123+
placement="left",
124+
)
114125

126+
popover_time_control = dbc.Popover(
127+
[
128+
dbc.PopoverHeader("Time Control Filter"),
129+
dbc.PopoverBody(
130+
"Players have a specific time to make their moves. The games in the dataset follow this convention: Bullet Games (0-3 minutes), Blitz(3-10 minutes), Classical(10 minutes+). Note: Lichess uses a slight different system today."
131+
),
132+
],
133+
trigger="hover",
134+
target="dropdown_time_control",
135+
placement="left",
136+
)
115137

116-
popover_status = dbc.Popover([
117-
dbc.PopoverHeader("Status of the Game"),
118-
dbc.PopoverBody("Games can be over in a myriad of ways, either by checkmate, draw, player resignation, or when a player runs out of time. Filter the games by these conditions here."),
119-
],trigger="hover",target="dropdown_status",placement="left")
120-
121-
popover_time_control = dbc.Popover([
122-
dbc.PopoverHeader("Time Control Filter"),
123-
dbc.PopoverBody("Players have a specific time to make their moves. The games in the dataset follow this convention: Bullet Games (0-3 minutes), Blitz(3-10 minutes), Classical(10 minutes+). Note: Lichess uses a slight different system today."),
124-
125-
],trigger="hover",target="dropdown_time_control",placement="left")
126-
127-
popover_game_type = dbc.Popover([
128-
dbc.PopoverHeader("Type of Competitive Setting"),
129-
dbc.PopoverBody("This dataset contains games played in specific tournaments, hosted by Lichess."),
130-
131-
],trigger="hover",target="dropdown_game_type",placement="left")
132-
133-
about_this = html.Div([
134-
dbc.Button("About this Visualization",id="abt_us"),
135-
dbc.Popover([
136-
dbc.PopoverHeader("Powered by Lichess"),
137-
dbc.PopoverBody("This visualization is powered by a dataset of games played in April, 2017, sourced from the publically available lichess database.\nAuthors:Frederico Santos, Rupesh Baradi, Tiago Ramos.\nNova IMS,Data Visualization Course, 2021."),
138-
],trigger="click",target="abt_us"),"stuff"])
138+
popover_game_type = dbc.Popover(
139+
[
140+
dbc.PopoverHeader("Type of Competitive Setting"),
141+
dbc.PopoverBody(
142+
"This dataset contains games played in specific tournaments, hosted by Lichess."
143+
),
144+
],
145+
trigger="hover",
146+
target="dropdown_game_type",
147+
placement="left",
148+
)
139149

150+
about_this = html.Div(
151+
[
152+
dbc.Button("About this Visualization", id="abt_us"),
153+
dbc.Popover(
154+
[
155+
dbc.PopoverHeader("Powered by Lichess"),
156+
dbc.PopoverBody(
157+
"This visualization is powered by a dataset of games played in April, 2017, sourced from the publically available lichess database.\nAuthors:Frederico Santos, Rupesh Baradi, Tiago Ramos.\nNova IMS,Data Visualization Course, 2021."
158+
),
159+
],
160+
trigger="click",
161+
target="abt_us",
162+
),
163+
"stuff",
164+
]
165+
)
140166

141167

142168
# Set stylesheets and app.
@@ -385,7 +411,8 @@ def board_output(df, col_list):
385411
dbc.DropdownMenuItem("Resignation", id="st_resign", n_clicks=0),
386412
dbc.DropdownMenuItem("Time Forfeit", id="st_outoftime", n_clicks=0),
387413
],
388-
label="Status",id="dropdown_status"
414+
label="Status",
415+
id="dropdown_status",
389416
)
390417

391418
dropdown_winner = dbc.Collapse(
@@ -396,7 +423,8 @@ def board_output(df, col_list):
396423
dbc.DropdownMenuItem("White", id="wn_white", n_clicks=0),
397424
dbc.DropdownMenuItem("Black", id="wn_black", n_clicks=0),
398425
],
399-
label="Winning Side",id="dropdown_winner"
426+
label="Winning Side",
427+
id="dropdown_winner",
400428
),
401429
id="wn_menu",
402430
)
@@ -411,7 +439,8 @@ def board_output(df, col_list):
411439
dbc.DropdownMenuItem("Classical", id="tc_classic", n_clicks=0),
412440
dbc.DropdownMenuItem("No Time Control", id="tc_none", n_clicks=0),
413441
],
414-
label="Time Control",id="dropdown_time_control"
442+
label="Time Control",
443+
id="dropdown_time_control",
415444
)
416445

417446
dropdown_game_type = dbc.DropdownMenu(
@@ -421,17 +450,21 @@ def board_output(df, col_list):
421450
dbc.DropdownMenuItem("Standard", id="gt_std", n_clicks=0),
422451
dbc.DropdownMenuItem("Tournament", id="gt_tourney", n_clicks=0),
423452
],
424-
label="Game Type",id="dropdown_game_type"
453+
label="Game Type",
454+
id="dropdown_game_type",
425455
)
426456

427457
dropdown_menus = dbc.Row(
428458
style={"margin-bottom": margin_bottom},
429459
justify="center",
430460
children=[
431-
dropdown_status,popover_status,
461+
dropdown_status,
462+
popover_status,
432463
dropdown_winner,
433-
dropdown_time_control,popover_time_control,
434-
dropdown_game_type,popover_game_type
464+
dropdown_time_control,
465+
popover_time_control,
466+
dropdown_game_type,
467+
popover_game_type,
435468
],
436469
)
437470

@@ -455,7 +488,7 @@ def board_output(df, col_list):
455488
c_elo_slider,
456489
c_moves_slider,
457490
dropdown_menus,
458-
about_this
491+
about_this,
459492
]
460493
),
461494
# CHESS BOARD COLUMN

apps/dash-chess-analytics/chess_app.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
# Read the .csv file with the preprocessed data.
2424
df = pd.read_csv(
2525
"chess_app.csv",
26-
dtype={"pawns": int, "knights": int,
27-
"bishops": int, "rooks": int, "queens": int},
26+
dtype={"pawns": int, "knights": int, "bishops": int, "rooks": int, "queens": int},
2827
converters={"wKing_sqr": ast.literal_eval, "bKing_sqr": ast.literal_eval},
2928
)
3029

@@ -35,10 +34,13 @@
3534

3635
# FILLER STUFF ~ LET'S KEEP THIS FILE CLEAN, have other .py files with everything!
3736
x_coords = ["A", "B", "C", "D", "E", "F", "G", "H"]
38-
replacer = {i+1: x for i, x in enumerate(x_coords)}
39-
df = df.stack().reset_index().rename(
40-
columns={"level_0": "rows", "level_1": "cols", 0: "freq"})
41-
df.iloc[:, 0:2] = df.iloc[:, 0:2].apply(lambda x: x+1)
37+
replacer = {i + 1: x for i, x in enumerate(x_coords)}
38+
df = (
39+
df.stack()
40+
.reset_index()
41+
.rename(columns={"level_0": "rows", "level_1": "cols", 0: "freq"})
42+
)
43+
df.iloc[:, 0:2] = df.iloc[:, 0:2].apply(lambda x: x + 1)
4244
df["letters"] = df.cols.replace(replacer)
4345

4446
# Set stylesheets and app.
@@ -55,10 +57,7 @@
5557
style={"backgroundColor": colors["background"]},
5658
children=[
5759
html.Div(
58-
[
59-
html.H2("Chess App"),
60-
html.Img(src="/assets/chess-app.jpg"),
61-
],
60+
[html.H2("Chess App"), html.Img(src="/assets/chess-app.jpg"),],
6261
className="banner",
6362
),
6463
html.Div(
@@ -68,8 +67,7 @@
6867
html.Label("Range Slider"),
6968
dcc.RangeSlider(
7069
id="rangeslider",
71-
marks={i: "label {}".format(i)
72-
for i in range(0, 5)},
70+
marks={i: "label {}".format(i) for i in range(0, 5)},
7371
min=0,
7472
max=5,
7573
value=[0, 1],

apps/dash-chess-analytics/chessboard.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ def getBoard(fig):
8282
x_black = []
8383
for i in range(8):
8484
if (i % 2) == 0:
85-
x_black += list(range(0,8,2))
85+
x_black += list(range(0, 8, 2))
8686
else:
87-
x_black += list(range(1,8,2))
88-
87+
x_black += list(range(1, 8, 2))
88+
8989
x_white = []
9090
for i in range(8):
9191
if (i % 2) == 0:
92-
x_white += list(range(1,8,2))
92+
x_white += list(range(1, 8, 2))
9393
else:
94-
x_white += list(range(0,8,2))
94+
x_white += list(range(0, 8, 2))
9595
fig.add_trace(
9696
go.Scatter(
9797
x0=0,
@@ -163,4 +163,4 @@ def getHeatmap(dataframe: pd.DataFrame):
163163
# TODO
164164
hovertemplate="<b># Games:</b> %{hovertext}<extra></extra>",
165165
)
166-
return heatmap
166+
return heatmap

apps/dash-chess-analytics/styles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
colors = {
33
"background": "#303030",
44
"text": "#7FDBFF",
5-
}
5+
}

apps/dash-fifa-dashboard/app_final.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,10 @@
274274
controls = dbc.Card(
275275
[
276276
dbc.FormGroup(
277-
[
278-
html.Label("Choose an Attribute:"),
279-
html.Br(),
280-
metric1_dropdown,
281-
]
277+
[html.Label("Choose an Attribute:"), html.Br(), metric1_dropdown,]
282278
),
283279
dbc.FormGroup(
284-
[
285-
html.Label("Choose an Attribute:"),
286-
html.Br(),
287-
metric2_dropdown,
288-
]
280+
[html.Label("Choose an Attribute:"), html.Br(), metric2_dropdown,]
289281
),
290282
dbc.FormGroup(
291283
[html.Label("Choose an Attribute:"), html.Br(), metric3_dropdown]
@@ -298,11 +290,7 @@
298290
controls_club = dbc.Card(
299291
[
300292
dbc.FormGroup(
301-
[
302-
html.Label("Choose a League:"),
303-
html.Br(),
304-
metric_club_dropdown1,
305-
]
293+
[html.Label("Choose a League:"), html.Br(), metric_club_dropdown1,]
306294
),
307295
dbc.FormGroup(
308296
[
@@ -654,17 +642,11 @@ def bar_plot(input_value1, input_value2, input_value3, age):
654642
),
655643
)
656644

657-
layout_bar1 = dict(
658-
xaxis=dict(title="League", tickangle=45),
659-
)
645+
layout_bar1 = dict(xaxis=dict(title="League", tickangle=45),)
660646

661-
layout_bar2 = dict(
662-
xaxis=dict(title="League", tickangle=45),
663-
)
647+
layout_bar2 = dict(xaxis=dict(title="League", tickangle=45),)
664648

665-
layout_bar3 = dict(
666-
xaxis=dict(title="League", tickangle=45),
667-
)
649+
layout_bar3 = dict(xaxis=dict(title="League", tickangle=45),)
668650
fig1 = go.Figure(data=data_bar1, layout=layout_bar1)
669651
fig1.update_traces(
670652
marker_color="rgb(133,61,246)",

0 commit comments

Comments
 (0)