Skip to content

Commit fed27c0

Browse files
committed
fixing yet again some other tests
Signed-off-by: DONNOT Benjamin <[email protected]>
1 parent 00c114b commit fed27c0

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

grid2op/Environment/environment.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ def reset_grid(self,
980980
self._backend_action = self._backend_action_class()
981981

982982
if self._init_obs is not None:
983+
# NB this is called twice (once at the end of reset), this is the first call
983984
self._reset_to_orig_state(self._init_obs)
984985

985986
init_action = None
@@ -1443,6 +1444,11 @@ def reset(self,
14431444
self._observation_space.reset(self)
14441445
self._observation_space.set_real_env_kwargs(self)
14451446
self._called_from_reset = False
1447+
1448+
# reset cooldowns and all
1449+
if self._init_obs is not None:
1450+
# NB this is called twice (once in reset_grid), this is the second call
1451+
self._reset_to_orig_state(self._init_obs)
14461452
# force the first observation to be generated properly
14471453
self._last_obs = None
14481454
return self.get_obs()

grid2op/tests/test_multi_steps_env.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ def test_cooldown(self):
8989
un_act = self.env.action_space({"set_line_status": [(5, +1)]})
9090
obs = self.env.reset()
9191
obs, *_ = self.env.step(act)
92-
assert obs.time_before_cooldown_line[5] == 3
92+
assert obs.time_before_cooldown_line[5] == 3, f"{obs.time_before_cooldown_line[5]} vs 3"
9393

9494
forecast_env = obs.get_forecast_env()
9595
f_obs = forecast_env.reset()
96-
assert f_obs.time_before_cooldown_line[5] == 3
96+
assert f_obs.time_before_cooldown_line[5] == 3, f"{f_obs.time_before_cooldown_line[5]} vs 3"
9797
f_obs2, *_ = forecast_env.step(self.dn)
98-
assert f_obs2.time_before_cooldown_line[5] == 2
98+
assert f_obs2.time_before_cooldown_line[5] == 2, f"{f_obs2.time_before_cooldown_line[5]} vs 2"
9999
f_obs3, *_ = forecast_env.step(self.dn)
100-
assert f_obs3.time_before_cooldown_line[5] == 1
100+
assert f_obs3.time_before_cooldown_line[5] == 1, f"{f_obs3.time_before_cooldown_line[5]} vs 1"
101101
f_obs4, r, done, info = forecast_env.step(un_act)
102-
assert f_obs4.time_before_cooldown_line[5] == 0
102+
assert f_obs4.time_before_cooldown_line[5] == 0, f"{f_obs4.time_before_cooldown_line[5]} vs 0"
103103
assert info["is_illegal"] # because cooldown is 1 when i took the action
104104

105105
# now I can reco

0 commit comments

Comments
 (0)