Skip to content

Commit

Permalink
Improve warning message (#570)
Browse files Browse the repository at this point in the history
* Improve warning message

* Improve wording
  • Loading branch information
tsmbland authored Nov 19, 2024
1 parent 35b4ecd commit ef7b7f1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/muse/mca.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,17 @@ def check_demand_fulfillment(market: Dataset, tol: float) -> bool:
"""
from logging import getLogger

future = market.year[-1]
future = market.year[-1].item()
delta = (market.supply - market.consumption).sel(year=future)
unmet = (delta < tol).any([u for u in delta.dims if u != "commodity"])

if unmet.any():
commodities = ", ".join(unmet.commodity.sel(commodity=unmet.values).values)
getLogger(__name__).warning(f"Check growth constraints for {commodities}.")
msg = (
f"Consumption exceeds supply in the year {future} for the following "
f"commodities: {commodities} "
)
getLogger(__name__).warning(msg)

return False

Expand Down

0 comments on commit ef7b7f1

Please sign in to comment.