Spaces:
Sleeping
Sleeping
Durand D'souza
commited on
Auto update equity share
Browse files
schema.py
CHANGED
|
@@ -83,7 +83,7 @@ class SolarPVAssumptions(BaseModel):
|
|
| 83 |
float,
|
| 84 |
Field(
|
| 85 |
ge=1,
|
| 86 |
-
le=
|
| 87 |
title="Debt Service Coverage Ratio",
|
| 88 |
description="Debt service coverage ratio",
|
| 89 |
),
|
|
|
|
| 83 |
float,
|
| 84 |
Field(
|
| 85 |
ge=1,
|
| 86 |
+
le=10,
|
| 87 |
title="Debt Service Coverage Ratio",
|
| 88 |
description="Debt service coverage ratio",
|
| 89 |
),
|
ui.py
CHANGED
|
@@ -96,7 +96,7 @@ def process_inputs(
|
|
| 96 |
|
| 97 |
|
| 98 |
def update_equity_from_debt(debt_pct):
|
| 99 |
-
return 1 - debt_pct
|
| 100 |
|
| 101 |
|
| 102 |
def get_params(request: gr.Request) -> Dict:
|
|
@@ -345,9 +345,10 @@ with gr.Blocks(theme="citrus", title="Renewable LCOE API") as interface:
|
|
| 345 |
outputs=[dcsr, debt_pct_of_capital_cost, equity_pct_of_capital_cost],
|
| 346 |
)
|
| 347 |
|
| 348 |
-
#
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
|
|
|
|
|
| 96 |
|
| 97 |
|
| 98 |
def update_equity_from_debt(debt_pct):
|
| 99 |
+
return gr.update(value=1 - debt_pct)
|
| 100 |
|
| 101 |
|
| 102 |
def get_params(request: gr.Request) -> Dict:
|
|
|
|
| 345 |
outputs=[dcsr, debt_pct_of_capital_cost, equity_pct_of_capital_cost],
|
| 346 |
)
|
| 347 |
|
| 348 |
+
# Add debt percentage change listener
|
| 349 |
+
debt_pct_of_capital_cost.change(
|
| 350 |
+
fn=update_equity_from_debt,
|
| 351 |
+
inputs=[debt_pct_of_capital_cost],
|
| 352 |
+
outputs=[equity_pct_of_capital_cost],
|
| 353 |
+
trigger_mode="always_last"
|
| 354 |
+
)
|