Spaces:
Sleeping
Sleeping
Kaveh commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -464,7 +464,7 @@ def filter_and_analyze_time_forfeits(df):
|
|
| 464 |
# =============================================
|
| 465 |
def perform_full_analysis(username, time_period_key, perf_type, selected_titles_list, progress=gr.Progress(track_tqdm=True)):
|
| 466 |
df, status_msg = load_from_lichess_api(username, time_period_key, perf_type, DEFAULT_RATED_ONLY, ECO_MAPPING, progress)
|
| 467 |
-
num_outputs =
|
| 468 |
if not isinstance(df, pd.DataFrame) or df.empty:
|
| 469 |
return status_msg, pd.DataFrame(), *([None] * (num_outputs - 2))
|
| 470 |
try:
|
|
@@ -478,7 +478,9 @@ def perform_full_analysis(username, time_period_key, perf_type, selected_titles_
|
|
| 478 |
d = len(df[df['PlayerResultNumeric'] == 0.5])
|
| 479 |
wr = (w / total_g * 100) if total_g > 0 else 0
|
| 480 |
avg_opp = df['OpponentElo'].mean()
|
| 481 |
-
|
|
|
|
|
|
|
| 482 |
fig_games_yr = plot_games_per_year(df)
|
| 483 |
fig_wr_yr = plot_win_rate_per_year(df)
|
| 484 |
fig_perf_tc = plot_performance_by_time_control(df)
|
|
@@ -530,7 +532,7 @@ def perform_full_analysis(username, time_period_key, perf_type, selected_titles_
|
|
| 530 |
df_titled_h2h, fig_tf_summary, fig_tf_tc, df_tf_list, fig_term_all)
|
| 531 |
except Exception as e:
|
| 532 |
error_msg = f"🚨 Error generating results: {e}\n{traceback.format_exc()}"
|
| 533 |
-
return error_msg, pd.DataFrame(), *([None] * num_outputs)
|
| 534 |
|
| 535 |
# =============================================
|
| 536 |
# Gradio Interface Definition
|
|
|
|
| 464 |
# =============================================
|
| 465 |
def perform_full_analysis(username, time_period_key, perf_type, selected_titles_list, progress=gr.Progress(track_tqdm=True)):
|
| 466 |
df, status_msg = load_from_lichess_api(username, time_period_key, perf_type, DEFAULT_RATED_ONLY, ECO_MAPPING, progress)
|
| 467 |
+
num_outputs = 33 # Adjusted to match the actual number of outputs
|
| 468 |
if not isinstance(df, pd.DataFrame) or df.empty:
|
| 469 |
return status_msg, pd.DataFrame(), *([None] * (num_outputs - 2))
|
| 470 |
try:
|
|
|
|
| 478 |
d = len(df[df['PlayerResultNumeric'] == 0.5])
|
| 479 |
wr = (w / total_g * 100) if total_g > 0 else 0
|
| 480 |
avg_opp = df['OpponentElo'].mean()
|
| 481 |
+
# Fixed formatting issue
|
| 482 |
+
avg_opp_display = f"{avg_opp:.0f}" if not pd.isna(avg_opp) else 'N/A'
|
| 483 |
+
overview_stats_md = f"**Total:** {total_g:,} | **WR:** {wr:.1f}% | **W/L/D:** {w}/{l}/{d} | **Avg Opp:** {avg_opp_display}"
|
| 484 |
fig_games_yr = plot_games_per_year(df)
|
| 485 |
fig_wr_yr = plot_win_rate_per_year(df)
|
| 486 |
fig_perf_tc = plot_performance_by_time_control(df)
|
|
|
|
| 532 |
df_titled_h2h, fig_tf_summary, fig_tf_tc, df_tf_list, fig_term_all)
|
| 533 |
except Exception as e:
|
| 534 |
error_msg = f"🚨 Error generating results: {e}\n{traceback.format_exc()}"
|
| 535 |
+
return error_msg, pd.DataFrame(), *([None] * (num_outputs - 2))
|
| 536 |
|
| 537 |
# =============================================
|
| 538 |
# Gradio Interface Definition
|