Skip to content

Commit 7291e31

Browse files
committed
fix broken tests, wrong env attribute was set
Signed-off-by: DONNOT Benjamin <[email protected]>
1 parent 0ce7b57 commit 7291e31

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

grid2op/Backend/backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ def next_grid_state(self,
14641464
iter_num = 0
14651465
while True:
14661466
# simulate the cascading failure
1467-
lines_flows = 1.0 * self.get_line_flow()
1467+
lines_flows = self.get_line_flow()
14681468
thermal_limits = self.get_thermal_limit()
14691469
lines_status = self.get_line_status()
14701470

grid2op/tests/BaseBackendTest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ def test_next_grid_state_multiple_iteration_cooldown(self):
17951795
th_lims[2] = 18849.43 / 1.6 # disconnected at second iteration
17961796
self.backend.set_thermal_limit(th_lims)
17971797

1798-
env._timestep_overflow[0] = 2 # already 1 step on overflow
1798+
env._protection_counter[0] = 2 # already 1 step on overflow
17991799
disco, infos, conv_ = self.backend.next_grid_state(env, is_dc=False)
18001800
res_a = self.backend.lines_or_info()[-1]
18011801
assert conv_ is None
@@ -1882,7 +1882,7 @@ def test_nb_timestep_overflow_nodisc(self):
18821882
type(self.backend).set_no_storage()
18831883
self.backend.assert_grid_correct()
18841884

1885-
env._timestep_overflow[self.id_2nd_line_disco] = 0
1885+
env._protection_counter[self.id_2nd_line_disco] = 0
18861886
thermal_limit = 10 * self.lines_flows_init
18871887
thermal_limit[self.id_first_line_disco] = (
18881888
self.lines_flows_init[self.id_first_line_disco] / 2
@@ -1924,7 +1924,7 @@ def test_nb_timestep_overflow_nodisc_2(self):
19241924
type(self.backend).set_no_storage()
19251925
self.backend.assert_grid_correct()
19261926

1927-
env._timestep_overflow[self.id_2nd_line_disco] = 1
1927+
env._protection_counter[self.id_2nd_line_disco] = 1
19281928

19291929
thermal_limit = 10 * self.lines_flows_init
19301930
thermal_limit[self.id_first_line_disco] = (
@@ -1967,8 +1967,7 @@ def test_nb_timestep_overflow_disc2(self):
19671967
type(self.backend).set_no_storage()
19681968
self.backend.assert_grid_correct()
19691969

1970-
env._timestep_overflow[self.id_2nd_line_disco] = 2
1971-
1970+
env._protection_counter[self.id_2nd_line_disco] = 2
19721971
thermal_limit = 10 * self.lines_flows_init
19731972
thermal_limit[self.id_first_line_disco] = (
19741973
self.lines_flows_init[self.id_first_line_disco] / 2
@@ -1978,7 +1977,7 @@ def test_nb_timestep_overflow_disc2(self):
19781977

19791978
disco, infos, conv_ = self.backend.next_grid_state(env, is_dc=False)
19801979
assert conv_ is None
1981-
assert len(infos) == 2 # check that there is a cascading failure of length 2
1980+
assert len(infos) == 2, f"{len(infos)} vs 2" # check that there is a cascading failure of length 2
19821981
assert disco[self.id_first_line_disco] >= 0
19831982
assert disco[self.id_2nd_line_disco] >= 0
19841983
assert np.sum(disco >= 0) == 2
@@ -2394,6 +2393,7 @@ def test_obs_from_same_chronic(self):
23942393
assert np.all(obs1.line_status == obs2.line_status)
23952394
assert np.all(obs1.topo_vect == obs2.topo_vect)
23962395
assert np.all(obs1.timestep_overflow == obs2.timestep_overflow)
2396+
assert np.all(obs1.timestep_protection_engaged == obs2.timestep_protection_engaged)
23972397
assert np.all(obs1.time_before_cooldown_line == obs2.time_before_cooldown_line)
23982398
assert np.all(obs1.time_before_cooldown_sub == obs2.time_before_cooldown_sub)
23992399
assert np.all(obs1.time_next_maintenance == obs2.time_next_maintenance)

0 commit comments

Comments
 (0)