Skip to content

Commit

Permalink
clarify exceptions in from_microgrid
Browse files Browse the repository at this point in the history
  • Loading branch information
ahalev committed Dec 17, 2022
1 parent 21fc24f commit c1f1d55
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pymgrid/envs/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ def from_microgrid(cls, microgrid):
"""
try:
return cls(microgrid.module_tuples(), add_unbalanced_module=False)
modules = microgrid.modules
except AttributeError:
assert isinstance(microgrid, NonModularMicrogrid)
return cls.from_nonmodular(microgrid)
else:
return cls(modules.to_tuples(), add_unbalanced_module=False)

@classmethod
def from_nonmodular(cls, nonmodular):
Expand Down

0 comments on commit c1f1d55

Please sign in to comment.