Skip to content

Commit

Permalink
fix: avoid error when scaling from scenario with slightly negative ge…
Browse files Browse the repository at this point in the history
…neration (#128)
  • Loading branch information
danielolsen authored and dmuldrew committed Apr 6, 2020
1 parent 1920302 commit 25208cf
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -761,13 +761,16 @@ def set_capacity(self, no_congestion_cap_factor, prev_capacity,
self.prev_cap_factor = prev_cap_factor

# todo: calculate directly from scenario results
def set_generation(self, prev_generation):
def set_generation(self, prev_generation, tolerance=1e-3):
"""
Set generation from scenario run
:param prev_generation: generation from scenario run
:param {float, int} tolerance: tolerance for ignored negative values
"""
if ((-1 * tolerance) <= prev_generation < 0):
prev_generation = 0
assert (prev_generation >= 0), \
"prev_generation must be greater than zero"
f"prev_generation must be greater than zero. Got {prev_generation}"
self.prev_generation = prev_generation

def set_curtailment(self, prev_curtailment):
Expand Down

0 comments on commit 25208cf

Please sign in to comment.