Chloe Anastasiades commited on
Commit
c039999
·
unverified ·
1 Parent(s): 2eee49c

Default value for cost divider line when no points have costs (#83)

Browse files
Files changed (1) hide show
  1. leaderboard_transformer.py +10 -7
leaderboard_transformer.py CHANGED
@@ -383,14 +383,18 @@ def _plot_scatter_plotly(
383
  valid_cost_data = data_plot[data_plot[x_col_to_use].notna()].copy()
384
  missing_cost_data = data_plot[data_plot[x_col_to_use].isna()].copy()
385
 
386
- if not valid_cost_data.empty:
387
- max_reported_cost = valid_cost_data[x_col_to_use].max()
388
- # ---Calculate where to place the missing data and the divider line ---
389
- divider_line_x = max_reported_cost + (max_reported_cost/10)
390
- new_x_for_missing = max_reported_cost + (max_reported_cost/5)
 
 
 
 
391
 
 
392
  if not missing_cost_data.empty:
393
- missing_cost_data[x_col_to_use] = new_x_for_missing
394
  # --- Combine the two groups back together ---
395
  data_plot = pd.concat([valid_cost_data, missing_cost_data])
396
  else:
@@ -398,7 +402,6 @@ def _plot_scatter_plotly(
398
  else:
399
  # ---Handle the case where ALL costs are missing ---
400
  if not missing_cost_data.empty:
401
- missing_cost_data[x_col_to_use] = 0
402
  data_plot = missing_cost_data
403
  else:
404
  data_plot = pd.DataFrame()
 
383
  valid_cost_data = data_plot[data_plot[x_col_to_use].notna()].copy()
384
  missing_cost_data = data_plot[data_plot[x_col_to_use].isna()].copy()
385
 
386
+ # Hardcode for all missing costs for now, but ideally try to fallback
387
+ # to the max cost in the same figure in another split, if that one has data...
388
+ max_reported_cost = valid_cost_data[x_col_to_use].max() if not valid_cost_data.empty else 10
389
+
390
+ # ---Calculate where to place the missing data and the divider line ---
391
+ divider_line_x = max_reported_cost + (max_reported_cost/10)
392
+ new_x_for_missing = max_reported_cost + (max_reported_cost/5)
393
+ if not missing_cost_data.empty:
394
+ missing_cost_data[x_col_to_use] = new_x_for_missing
395
 
396
+ if not valid_cost_data.empty:
397
  if not missing_cost_data.empty:
 
398
  # --- Combine the two groups back together ---
399
  data_plot = pd.concat([valid_cost_data, missing_cost_data])
400
  else:
 
402
  else:
403
  # ---Handle the case where ALL costs are missing ---
404
  if not missing_cost_data.empty:
 
405
  data_plot = missing_cost_data
406
  else:
407
  data_plot = pd.DataFrame()