CarlyneB commited on
Commit
4ac6bf0
·
1 Parent(s): fddc24f

[FEAT] Clarify the way users must input resources

Browse files
Files changed (1) hide show
  1. tabs/tab1_inputs.py +9 -8
tabs/tab1_inputs.py CHANGED
@@ -119,7 +119,7 @@ def dialog_add_custom_resource(cost_sliders, edit_index: int | None = None, pres
119
  st.markdown('<p class="dialog-title">2 — Available quantity</p>', unsafe_allow_html=True)
120
 
121
  batch_amount = st.number_input(
122
- f"Available amount ({unit})",
123
  min_value=0.0,
124
  format="%.2f",
125
  value=float(existing["amount"]) if existing.get("amount") and existing.get("amount") != 0.0 else None,
@@ -462,15 +462,13 @@ def dialog_load_custom_batch():
462
 
463
  def render_custom_batch_inline(global_idx, batch, cost_sliders, unit):
464
  """Render a single custom batch inside its resource-group expander."""
465
- n_methods = len(batch["methods"])
466
  amount_val = float(batch["amount"])
467
- batch["unit"] = unit # keep in sync for Excel export
468
 
469
- # st.markdown(f"🆕 **{batch['name']}** — CDR methods: **{n_methods}**")
470
  with st.container(border=True):
471
  key_amount = f"custom_amount_{global_idx}"
472
  if key_amount not in st.session_state:
473
- st.session_state[key_amount] = amount_val
474
 
475
  col_amount, _, _, _ = st.columns(4)
476
  with col_amount:
@@ -479,9 +477,11 @@ def render_custom_batch_inline(global_idx, batch, cost_sliders, unit):
479
  min_value=0.0,
480
  format="%.2f",
481
  key=key_amount,
 
482
  )
483
- if new_amount != amount_val:
484
- st.session_state.custom_resources[global_idx]["amount"] = float(new_amount)
 
485
  st.session_state.pop("latest_result", None)
486
 
487
  col_min = f"Min ({unit}/MtCO₂)"
@@ -575,7 +575,8 @@ def render_tab(cost_sliders):
575
  st.markdown('<p class="objective_title">OBJECTIVE</p>', unsafe_allow_html=True)
576
  st.markdown(
577
  '<p class="text_with_border">This section lets you define the <strong>total available '
578
- 'quantities of each resource</strong> for the optimization model.</p>',
 
579
  unsafe_allow_html=True,
580
  )
581
 
 
119
  st.markdown('<p class="dialog-title">2 — Available quantity</p>', unsafe_allow_html=True)
120
 
121
  batch_amount = st.number_input(
122
+ label=f"Available amount ({unit})",
123
  min_value=0.0,
124
  format="%.2f",
125
  value=float(existing["amount"]) if existing.get("amount") and existing.get("amount") != 0.0 else None,
 
462
 
463
  def render_custom_batch_inline(global_idx, batch, cost_sliders, unit):
464
  """Render a single custom batch inside its resource-group expander."""
 
465
  amount_val = float(batch["amount"])
466
+ batch["unit"] = unit
467
 
 
468
  with st.container(border=True):
469
  key_amount = f"custom_amount_{global_idx}"
470
  if key_amount not in st.session_state:
471
+ st.session_state[key_amount] = amount_val if amount_val else None
472
 
473
  col_amount, _, _, _ = st.columns(4)
474
  with col_amount:
 
477
  min_value=0.0,
478
  format="%.2f",
479
  key=key_amount,
480
+ placeholder="0.0",
481
  )
482
+ new_amount_float = float(new_amount) if new_amount is not None else 0.0
483
+ if new_amount_float != amount_val:
484
+ st.session_state.custom_resources[global_idx]["amount"] = new_amount_float
485
  st.session_state.pop("latest_result", None)
486
 
487
  col_min = f"Min ({unit}/MtCO₂)"
 
575
  st.markdown('<p class="objective_title">OBJECTIVE</p>', unsafe_allow_html=True)
576
  st.markdown(
577
  '<p class="text_with_border">This section lets you define the <strong>total available '
578
+ 'quantities of each resource</strong> for the optimization model.<br>'
579
+ 'Availability is per <strong>year</strong> (rate) for the specific year the portfolio is being estimated, for example 2030, or 2050</p>',
580
  unsafe_allow_html=True,
581
  )
582