mgyigit commited on
Commit
b0c3a0a
·
verified ·
1 Parent(s): c24ce1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -13
app.py CHANGED
@@ -115,20 +115,15 @@ def colour_method(name: str) -> str:
115
  # darkest → lightest
116
  TOP5_GREENS = ["#006400", "#228B22", "#32CD32", "#7CFC00", "#ADFF2F"]
117
 
118
- def highlight_top5(col: pd.Series) -> list[str]:
119
- """Return a list of CSS strings for one numeric column."""
120
- # ignore non-numeric cols
121
  if not pd.api.types.is_numeric_dtype(col):
122
- return [""] * len(col)
123
-
124
- ranks = col.rank(ascending=False, method="first") # 1 = best
125
- styles = []
126
- for r in ranks:
127
- if r <= 5:
128
- styles.append(f"background-color:{TOP5_GREENS[int(r)-1]};")
129
- else:
130
- styles.append("")
131
- return styles
132
 
133
  def make_leaderboard_df(selected_methods=None, selected_metrics=None):
134
  """Fetch, tidy, colour, and return a Styler that Gradio will render."""
 
115
  # darkest → lightest
116
  TOP5_GREENS = ["#006400", "#228B22", "#32CD32", "#7CFC00", "#ADFF2F"]
117
 
118
+ def shade_top5(col: pd.Series) -> list[str]:
119
+ """Return background‐colour CSS for the best 5 numeric cells of a column."""
 
120
  if not pd.api.types.is_numeric_dtype(col):
121
+ return [""] * len(col) # leave non-numeric cols untouched
122
+ ranks = col.rank(ascending=False, method="first")
123
+ return [
124
+ f"background-color:{TOP5_GREENS[int(r)-1]};" if r <= 5 else ""
125
+ for r in ranks
126
+ ]
 
 
 
 
127
 
128
  def make_leaderboard_df(selected_methods=None, selected_metrics=None):
129
  """Fetch, tidy, colour, and return a Styler that Gradio will render."""