albertvillanova HF staff commited on
Commit
0d4c659
1 Parent(s): 81f1dd1

Simplify display_tab

Browse files
Files changed (1) hide show
  1. app.py +6 -24
app.py CHANGED
@@ -70,47 +70,29 @@ def load_result_dataframe(model_id):
70
  def display_results(df_1, df_2, task):
71
  df = pd.concat([df.set_index("index") for df in [df_1, df_2] if "index" in df.columns])
72
  df = df.T.rename_axis(columns=None)
73
- return display_results_tab(df, task), display_configs_tab(df, task)
74
 
75
 
76
- def display_results_tab(df, task):
77
  df = df.style.format(na_rep="")
78
  df.hide(
79
  [
80
  row
81
  for row in df.index
82
  if (
83
- not row.startswith("results.")
84
- or row.startswith("results.leaderboard.")
85
  or row.endswith(".alias")
86
- or (not row.startswith(f"results.{task}") if task != "All" else False)
87
  )
88
  ],
89
  axis="index",
90
  )
91
- start = len("results.leaderboard_") if task == "All" else len(f"results.{task} ")
92
  df.format_index(lambda idx: idx[start:].removesuffix(",none"), axis="index")
93
  return df.to_html()
94
 
95
 
96
- def display_configs_tab(df, task):
97
- df = df.style.format(na_rep="")
98
- df.hide(
99
- [
100
- row
101
- for row in df.index
102
- if (
103
- not row.startswith("configs.")
104
- or row.startswith("configs.leaderboard.")
105
- or row.endswith(".alias")
106
- or (not row.startswith(f"configs.{task}") if task != "All" else False)
107
- )
108
- ],
109
- axis="index",
110
- )
111
- start = len("configs.leaderboard_") if task == "All" else len(f"configs.{task} ")
112
- df.format_index(lambda idx: idx[start:], axis="index")
113
- return df.to_html()
114
 
115
 
116
  # if __name__ == "__main__":
 
70
  def display_results(df_1, df_2, task):
71
  df = pd.concat([df.set_index("index") for df in [df_1, df_2] if "index" in df.columns])
72
  df = df.T.rename_axis(columns=None)
73
+ return display_tab("results", df, task), display_tab("configs", df, task)
74
 
75
 
76
+ def display_tab(tab, df, task):
77
  df = df.style.format(na_rep="")
78
  df.hide(
79
  [
80
  row
81
  for row in df.index
82
  if (
83
+ not row.startswith(f"{tab}.")
84
+ or row.startswith(f"{tab}.leaderboard.")
85
  or row.endswith(".alias")
86
+ or (not row.startswith(f"{tab}.{task}") if task != "All" else False)
87
  )
88
  ],
89
  axis="index",
90
  )
91
+ start = len(f"{tab}.leaderboard_") if task == "All" else len(f"{tab}.{task} ")
92
  df.format_index(lambda idx: idx[start:].removesuffix(",none"), axis="index")
93
  return df.to_html()
94
 
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
 
98
  # if __name__ == "__main__":