Skip to content

Commit

Permalink
doc: add Exceptions to docstring for ChangeTable.add_bus()
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Dec 8, 2020
1 parent f933e2f commit 5726464
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions powersimdata/input/change_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ def add_bus(self, info):
the information needed to create a new bus.
Required keys: "lat", "lon", ["zone_id" XOR "zone_name"].
Optional key: "Pd".
:raises TypeError: if info is not a list.
:raises ValueError: if each element of info is not a dict with appropriate keys
and values.
"""
allowable_keys = {"lat", "lon", "zone_id", "zone_name", "Pd", "baseKV"}
defaults = {"Pd": 0, "baseKV": 230}
Expand All @@ -654,6 +657,8 @@ def add_bus(self, info):

try:
for i, new_bus in enumerate(info):
if not isinstance(new_bus, dict):
raise ValueError("Each entry in the list must be a dict")
new_bus = new_bus.copy()
if not set(new_bus.keys()) <= allowable_keys:
unknown_keys = set(new_bus.keys()) - allowable_keys
Expand Down

0 comments on commit 5726464

Please sign in to comment.