Skip to content

Commit

Permalink
refactor: add non-negativity check for plant scaling values
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Nov 13, 2020
1 parent 7e2154c commit 3dff028
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions powersimdata/input/change_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def _add_plant_entries(self, resource, ct_key, zone_name=None, plant_id=None):
load zone(s).
:param dict plant_id: identification numbers of plants. The key(s) is
(are) the id of the plant(s).
:raise ValueError: if any values within zone_name or plant_id are negative.
"""
self._check_resource(resource)
if bool(zone_name) or bool(plant_id) is True:
Expand All @@ -201,6 +202,8 @@ def _add_plant_entries(self, resource, ct_key, zone_name=None, plant_id=None):
except ValueError:
self.ct.pop(ct_key)
raise
if not all([v >= 0 for v in zone_name.values()]):
raise ValueError(f"All entries for {ct_key} must be non-negative")
if "zone_id" not in self.ct[ct_key]:
self.ct[ct_key]["zone_id"] = {}
for z in zone_name.keys():
Expand Down

0 comments on commit 3dff028

Please sign in to comment.