Skip to content

Commit

Permalink
fixing the fix to issue 66
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Oct 20, 2023
1 parent b3c9ab2 commit 655cb06
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lightsim2grid/tests/test_issue_66.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import warnings
from lightsim2grid import LightSimBackend
from grid2op.Action import PlayableAction
from grid2op.Rules import AlwaysLegal
import grid2op

class Issue66Tester(unittest.TestCase):
Expand All @@ -18,7 +19,13 @@ def setUp(self) -> None:
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
self.env = grid2op.make("educ_case14_storage", test=True, backend=LightSimBackend(),
action_class=PlayableAction)
action_class=PlayableAction,
gamerules_class=AlwaysLegal)
param = self.env.parameters
param.NB_TIMESTEP_COOLDOWN_LINE = 0
param.NB_TIMESTEP_COOLDOWN_SUB = 0
self.env.change_parameters(param)
self.env.change_forecast_parameters(param)
return super().setUp()

def tearDown(self) -> None:
Expand Down Expand Up @@ -47,6 +54,7 @@ def test_change_bus_load(self):
act = self.env.action_space({"set_bus": {"loads_id": [(9, 2)],
"lines_or_id": [(14, 2)]}})
obs, reward, done, info = self.env.step(act)
assert len(info['exception']) == 0
assert not done
# should not raise any RuntimeError

Expand All @@ -61,10 +69,11 @@ def test_change_bus_gen(self):
act = self.env.action_space({"set_bus": {"generators_id": [(0, 2)],
"lines_ex_id": [(0, 2)]}})
obs, reward, done, info = self.env.step(act)
assert len(info['exception']) == 0
assert not done
# should not raise any RuntimeError

# isolate the load
# isolate the generator
act = self.env.action_space({"set_bus": {"lines_ex_id": [(0, 1)]}})
obs, reward, done, info = self.env.step(act)
assert done
Expand All @@ -74,11 +83,13 @@ def test_disco_storage(self):
obs = self.env.reset()
act = self.env.action_space({"set_bus": {"storages_id": [(0, -1)]}})
obs, reward, done, info = self.env.step(act)
assert len(info['exception']) == 0
assert not done
# should not raise any RuntimeError

act = self.env.action_space({"storage_p": [(0, -1)]})
act = self.env.action_space({"set_storage": [(0, -1)]})
obs, reward, done, info = self.env.step(act)
assert len(info['exception']) == 0
assert not done
# should not raise any RuntimeError

Expand Down

0 comments on commit 655cb06

Please sign in to comment.