feat(fase2a): percent-mål mot baseline 0 reiser ValueError (S2.0)
This commit is contained in:
parent
8ec71c9814
commit
9311813080
2 changed files with 23 additions and 1 deletions
|
|
@ -420,6 +420,12 @@ def _goal_limit_if_reached(goal: GoalContract, observed_ore: int, baseline_ore:
|
|||
if goal.absolute_ore is not None and observed_ore >= goal.absolute_ore:
|
||||
return goal.absolute_ore
|
||||
if goal.percent is not None:
|
||||
if baseline_ore <= 0:
|
||||
raise ValueError(
|
||||
f"percent goal ({goal.percent}%) is meaningless against a non-positive baseline "
|
||||
f"({baseline_ore} øre): int(percent/100 * 0) == 0 would falsely read as 'goal "
|
||||
"reached'. Supply an absolute_ore target, or ensure the addressable baseline is > 0."
|
||||
)
|
||||
threshold = int(goal.percent / 100 * baseline_ore)
|
||||
if observed_ore >= threshold:
|
||||
return threshold
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue