Skip to content

Commit

Permalink
improve error message for power_type arg
Browse files Browse the repository at this point in the history
  • Loading branch information
robfitzgerald committed Sep 22, 2023
1 parent b461d11 commit 3a99709
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ def __init__(
self.step_size_seconds = data["step_size_seconds"] # seconds

if self.energy_type is None:
pt = data.get("power_type")
if pt is None:
pt_msg = "no power_type argument"
else:
pt_msg = f"invalid energy type '{data['power_type']}'"
raise AttributeError(
f"TabularPowercurve initialized with invalid energy type {self.energy_type}"
f"TabularPowercurve configuration has {pt_msg}; "
f"should be one of {{electric, gasoline}} "
)

charging_model = sorted(data["power_curve"], key=lambda x: x["energy_kwh"])
Expand Down

0 comments on commit 3a99709

Please sign in to comment.