Skip to content

Commit

Permalink
* nemo/generators.py (Generator): Don't divide by zero and catch the
Browse files Browse the repository at this point in the history
  exception as this produces a runtime warning. Avoid it instead.
  • Loading branch information
bje- committed Feb 17, 2024
1 parent a772cae commit d80398c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nemo/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def capfactor(self):
"""Capacity factor of this generator (in %)."""
supplied = sum(self.series_power.values())
hours = len(self.series_power)
try:
if self.capacity * hours == 0:
return float('nan')
else:
capfactor = supplied / (self.capacity * hours) * 100
return capfactor
except ZeroDivisionError:
return float('nan')

def lcoe(self, costs, years):
"""Calculate the LCOE in $/MWh."""
Expand Down

0 comments on commit d80398c

Please sign in to comment.