Commit
·
a37f146
1
Parent(s):
17519fc
feat: add current and highest rating
Browse files
app.py
CHANGED
@@ -104,6 +104,14 @@ def get_num_competitions_played(df: pd.DataFrame, is_tournament: bool) -> int:
|
|
104 |
return df[key_name].nunique()
|
105 |
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
def get_matches_per_competition_fig(df: pd.DataFrame, is_tournament: bool):
|
108 |
fig = plt.figure()
|
109 |
plt.title('Matches per competition')
|
@@ -242,6 +250,8 @@ def usatt_rating_analyzer(file_obj):
|
|
242 |
df, is_tournament = load_match_df(Path(file_obj.name))
|
243 |
|
244 |
# Create outputs.
|
|
|
|
|
245 |
n_competitions_played = get_num_competitions_played(df, is_tournament)
|
246 |
n_matches_played = len(df)
|
247 |
matches_per_competition_fig = get_matches_per_competition_fig(df, is_tournament)
|
@@ -256,7 +266,9 @@ def usatt_rating_analyzer(file_obj):
|
|
256 |
opponent_rating_distr_fig = get_opponent_rating_distr_fig(df)
|
257 |
opponent_rating_dist_over_time_fig = get_opponent_rating_dist_over_time_fig(df, is_tournament)
|
258 |
|
259 |
-
return (
|
|
|
|
|
260 |
n_matches_played,
|
261 |
matches_per_competition_fig,
|
262 |
opponent_name_word_cloud_fig,
|
@@ -292,6 +304,10 @@ with gr.Blocks() as demo:
|
|
292 |
|
293 |
with gr.Group():
|
294 |
with gr.Row():
|
|
|
|
|
|
|
|
|
295 |
with gr.Column():
|
296 |
num_comps_box = gr.Textbox(lines=1, label="Number of competitions (tournaments/leagues) played")
|
297 |
with gr.Column():
|
@@ -328,6 +344,8 @@ with gr.Blocks() as demo:
|
|
328 |
|
329 |
inputs = [input_file]
|
330 |
outputs = [
|
|
|
|
|
331 |
num_comps_box,
|
332 |
num_matches_box,
|
333 |
matches_per_comp_plot,
|
|
|
104 |
return df[key_name].nunique()
|
105 |
|
106 |
|
107 |
+
def get_current_rating(df: pd.DataFrame) -> int:
|
108 |
+
return df.rating.iloc[0]
|
109 |
+
|
110 |
+
|
111 |
+
def get_max_rating(df: pd.DataFrame) -> int:
|
112 |
+
return df.rating.max()
|
113 |
+
|
114 |
+
|
115 |
def get_matches_per_competition_fig(df: pd.DataFrame, is_tournament: bool):
|
116 |
fig = plt.figure()
|
117 |
plt.title('Matches per competition')
|
|
|
250 |
df, is_tournament = load_match_df(Path(file_obj.name))
|
251 |
|
252 |
# Create outputs.
|
253 |
+
current_rating = get_current_rating(df)
|
254 |
+
peak_rating = get_max_rating(df)
|
255 |
n_competitions_played = get_num_competitions_played(df, is_tournament)
|
256 |
n_matches_played = len(df)
|
257 |
matches_per_competition_fig = get_matches_per_competition_fig(df, is_tournament)
|
|
|
266 |
opponent_rating_distr_fig = get_opponent_rating_distr_fig(df)
|
267 |
opponent_rating_dist_over_time_fig = get_opponent_rating_dist_over_time_fig(df, is_tournament)
|
268 |
|
269 |
+
return (current_rating,
|
270 |
+
peak_rating,
|
271 |
+
n_competitions_played,
|
272 |
n_matches_played,
|
273 |
matches_per_competition_fig,
|
274 |
opponent_name_word_cloud_fig,
|
|
|
304 |
|
305 |
with gr.Group():
|
306 |
with gr.Row():
|
307 |
+
with gr.Column():
|
308 |
+
current_rating_box = gr.Textbox(lines=1, label="Current rating")
|
309 |
+
with gr.Column():
|
310 |
+
peak_rating_box = gr.Textbox(lines=1, label="Highest rating")
|
311 |
with gr.Column():
|
312 |
num_comps_box = gr.Textbox(lines=1, label="Number of competitions (tournaments/leagues) played")
|
313 |
with gr.Column():
|
|
|
344 |
|
345 |
inputs = [input_file]
|
346 |
outputs = [
|
347 |
+
current_rating_box,
|
348 |
+
peak_rating_box,
|
349 |
num_comps_box,
|
350 |
num_matches_box,
|
351 |
matches_per_comp_plot,
|