Skip to content

Commit

Permalink
better dealing with env.reset in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marota committed Jun 18, 2021
1 parent 77db4ea commit e2346c2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions grid2op/tests/test_AlarmScore.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_reward_correct_alarm_only_cascade_right_zone(self):
param = Parameters()
param.init_from_dict({'MAX_LINE_STATUS_CHANGED': 999})
self.env.change_parameters(param)
self.env.reset()
self.env.reset()# env.reset() on saute sur le scénario suivant, en plus de mettre à jour les paramètres

act = self.env.action_space()
alarm_zone_id=1 #right zone
Expand Down Expand Up @@ -273,7 +273,7 @@ def test_reward_correct_alarm_only_cascade_bad_zone(self):
param = Parameters()
param.init_from_dict({'MAX_LINE_STATUS_CHANGED': 999})
self.env.change_parameters(param)
self.env.reset()
self.env.reset()# env.reset() on saute sur le scénario suivant, en plus de mettre à jour les paramètres

act = self.env.action_space()
alarm_zone_id=0 #wrong zone
Expand Down Expand Up @@ -500,9 +500,8 @@ def test_alarm_after_line_diconnection_score_low_2(self):
param = self.env.parameters
param.init_from_dict({'ALARM_WINDOW_SIZE': 5, 'ALARM_BEST_TIME': 7})
self.env.change_parameters(param)
self.env.seed(0)
self.env.reset()
self.env.reset()
self.env.reset()#2 env.reset() pour revenir sur le scénario de départ dans un jeu de 2 scénarios
###

# changing thermal limits to create an overload since the beginning and a slow cascading failure
Expand All @@ -525,6 +524,10 @@ def test_alarm_after_line_diconnection_score_low_2(self):
if (t == 2):
print("stop")
obs, reward, done, info = self.env.step(act)
if not done:
disc_lines_before_cascade.append(list(np.where(info["disc_lines"]==0)[0]))
else:
disc_lines_in_cascade=list(np.where(info["disc_lines"]==0)[0])
t+=1

assert np.round(reward,2)== 0.24
Expand Down

0 comments on commit e2346c2

Please sign in to comment.