James McCool commited on
Commit
866355a
·
1 Parent(s): c7464dc

Update input fields in app.py: add unique keys to selectboxes and number inputs for sorting and trimming variables, enhancing state management and user experience in the portfolio trimming process.

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -913,25 +913,25 @@ with tab2:
913
  st.write("Sorting and trimming variables:")
914
  perf_var, own_var = st.columns(2)
915
  with perf_var:
916
- performance_type = st.selectbox("Sorting variable", ['median', 'Finish_percentile'])
917
  with own_var:
918
- own_type = st.selectbox("Trimming variable", ['Own', 'Geomean', 'Weighted Own'])
919
-
920
- trim_slack_var = st.number_input("Trim slack (percentile addition to trimming variable ceiling)", value=0.0, min_value=0.0, max_value=1.0, step=0.1)
921
 
922
  st.write("Sorting threshold range:")
923
  min_sort, max_sort = st.columns(2)
924
  with min_sort:
925
- performance_threshold_low = st.number_input("Min", value=0.0, min_value=0.0, step=1.0)
926
  with max_sort:
927
- performance_threshold_high = st.number_input("Max", value=st.session_state['portfolio'][performance_type].max(), min_value=0.0, step=1.0)
928
 
929
  st.write("Trimming threshold range:")
930
  min_trim, max_trim = st.columns(2)
931
  with min_trim:
932
- own_threshold_low = st.number_input("Min", value=0.0, min_value=0.0, step=1.0)
933
  with max_trim:
934
- own_threshold_high = st.number_input("Max", value=st.session_state['portfolio'][own_type].max(), min_value=0.0, step=1.0)
935
 
936
  submitted = st.form_submit_button("Trim")
937
  if submitted:
 
913
  st.write("Sorting and trimming variables:")
914
  perf_var, own_var = st.columns(2)
915
  with perf_var:
916
+ performance_type = st.selectbox("Sorting variable", ['median', 'Finish_percentile'], key='sort_var')
917
  with own_var:
918
+ own_type = st.selectbox("Trimming variable", ['Own', 'Geomean', 'Weighted Own'], key='trim_var')
919
+
920
+ trim_slack_var = st.number_input("Trim slack (percentile addition to trimming variable ceiling)", value=0.0, min_value=0.0, max_value=1.0, step=0.1, key='trim_slack')
921
 
922
  st.write("Sorting threshold range:")
923
  min_sort, max_sort = st.columns(2)
924
  with min_sort:
925
+ performance_threshold_low = st.number_input("Min", value=0.0, min_value=0.0, step=1.0, key='min_sort')
926
  with max_sort:
927
+ performance_threshold_high = st.number_input("Max", value=st.session_state['portfolio'][performance_type].max(), min_value=0.0, step=1.0, key='max_sort')
928
 
929
  st.write("Trimming threshold range:")
930
  min_trim, max_trim = st.columns(2)
931
  with min_trim:
932
+ own_threshold_low = st.number_input("Min", value=0.0, min_value=0.0, step=1.0, key='min_trim')
933
  with max_trim:
934
+ own_threshold_high = st.number_input("Max", value=st.session_state['portfolio'][own_type].max(), min_value=0.0, step=1.0, key='max_trim')
935
 
936
  submitted = st.form_submit_button("Trim")
937
  if submitted: