Spaces:
Running
Running
Download utils/data_utils.py from CGdev/CRRA_optimisation_tool: direct link, hf CLI and curl.
- Browser
- Download file 826 Bytes
-
https://huggingface.co/spaces/CGdev/CRRA_optimisation_tool/resolve/5cbcf0f4c6b16ad50cfc23ce4f7b2b380c1957d6/utils/data_utils.py
- Command line
-
hf download hf://spaces/CGdev/CRRA_optimisation_tool@5cbcf0f4c6b16ad50cfc23ce4f7b2b380c1957d6/utils/data_utils.py
-
curl -L -o data_utils.py https://huggingface.co/spaces/CGdev/CRRA_optimisation_tool/resolve/5cbcf0f4c6b16ad50cfc23ce4f7b2b380c1957d6/utils/data_utils.py
826 Bytes
| import json | |
| import streamlit as st | |
| def load_slider_data(): | |
| """Load slider data from a JSON file and cache it for performance.""" | |
| with open("data/cost_sliders.json") as f: | |
| return json.load(f) | |
| def render_resource_input(name_clean, r, tooltip=None): | |
| if tooltip: | |
| st.markdown( | |
| f"""<span title="{tooltip}" style="font-weight: 500;">{name_clean} <sup style="color:#999;">ℹ️</sup></span>""", | |
| unsafe_allow_html=True | |
| ) | |
| else: | |
| st.markdown(f"**{name_clean}**") | |
| cap = st.number_input( | |
| label="", # Label shown above | |
| min_value=0.0, | |
| value=float(st.session_state.resource_caps.get(r, 0.0)), | |
| format="%.2f", | |
| key=f"cap_{r}" | |
| ) | |
| st.session_state.resource_caps[r] = cap | |