@@ -37,6 +37,7 @@ def demand_share(
3737
3838from collections .abc import Hashable , MutableMapping , Sequence
3939from functools import wraps
40+ from logging import getLogger
4041from typing import Any , Callable , cast
4142
4243import numpy as np
@@ -299,8 +300,18 @@ def new_and_retro(
299300
300301 # Make sure the total new/retro agent quantity = 1
301302 # TODO: ideally we should check this in the input layer
302- assert abs (total_retro_quantity - 1 ) < 1e-2
303- assert abs (total_new_quantity - 1 ) < 1e-2
303+ if abs (total_retro_quantity - 1 ) > 1e-2 :
304+ msg = (
305+ f"Total retrofit agent quantity in region { region } "
306+ f"is not 1: { total_retro_quantity } "
307+ )
308+ getLogger (__name__ ).critical (msg )
309+ if abs (total_new_quantity - 1 ) > 1e-2 :
310+ msg = (
311+ f"Total new agent quantity in region { region } "
312+ f"is not 1: { total_new_quantity } "
313+ )
314+ getLogger (__name__ ).critical (msg )
304315
305316 result = agent_concatenation (agent_demands )
306317 assert "year" not in result .dims
@@ -399,7 +410,9 @@ def standard_demand(
399410
400411 # Make sure the total agent quantity = 1
401412 # TODO: ideally we should check this in the input layer
402- assert abs (total_quantity - 1 ) < 1e-2
413+ if abs (total_quantity - 1 ) > 1e-2 :
414+ msg = f"Total agent quantity in region { region } is not 1: { total_quantity } "
415+ getLogger (__name__ ).critical (msg )
403416
404417 result = agent_concatenation (agent_demands )
405418 assert "year" not in result .dims
0 commit comments