Spaces:
Sleeping
Sleeping
[FIX] tab4: cap heatmap percentages at 100%, show percentages instead of exact values in chart data table
Browse files
tabs/tab4_optimization.py
CHANGED
|
@@ -675,7 +675,7 @@ def show_heatmap(df_result, resource_caps, method_costs, custom_resources=None,
|
|
| 675 |
used = resource_usage.get(r, {}).get(method, 0.0)
|
| 676 |
else:
|
| 677 |
used = normalized_costs.get(method, {}).get(r, 0.0) * df_result.at[method, f"{CO2_UNIT} removed"]
|
| 678 |
-
row_pct.append(used / cap * 100)
|
| 679 |
row_exact.append(used)
|
| 680 |
matrix_pct.append(row_pct)
|
| 681 |
matrix_exact.append(row_exact)
|
|
@@ -718,7 +718,11 @@ def show_heatmap(df_result, resource_caps, method_costs, custom_resources=None,
|
|
| 718 |
)
|
| 719 |
|
| 720 |
with st.expander("📊 View / download chart data"):
|
| 721 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 722 |
|
| 723 |
register_chart_data("Resource usage heatmap (% of cap)", df_export_pct)
|
| 724 |
register_chart_data("Resource usage exact values", df_export_exact)
|
|
|
|
| 675 |
used = resource_usage.get(r, {}).get(method, 0.0)
|
| 676 |
else:
|
| 677 |
used = normalized_costs.get(method, {}).get(r, 0.0) * df_result.at[method, f"{CO2_UNIT} removed"]
|
| 678 |
+
row_pct.append(min(used / cap * 100, 100.0))
|
| 679 |
row_exact.append(used)
|
| 680 |
matrix_pct.append(row_pct)
|
| 681 |
matrix_exact.append(row_exact)
|
|
|
|
| 718 |
)
|
| 719 |
|
| 720 |
with st.expander("📊 View / download chart data"):
|
| 721 |
+
df_pct_display = df_export_pct.copy()
|
| 722 |
+
for col in df_pct_display.columns:
|
| 723 |
+
if col != "Method":
|
| 724 |
+
df_pct_display[col] = df_pct_display[col].map(lambda x: f"{x:.1f}%")
|
| 725 |
+
st.dataframe(df_pct_display, width='stretch', hide_index=True)
|
| 726 |
|
| 727 |
register_chart_data("Resource usage heatmap (% of cap)", df_export_pct)
|
| 728 |
register_chart_data("Resource usage exact values", df_export_exact)
|