@@ -2522,10 +2522,12 @@ def test_change_line_status(self):
25222522 # Create change action
25232523 change_act = self .env .action_space ({"change_line_status" : change_status })
25242524 # Simulate & Step
2525- self .sim_obs , reward_sim , done_sim , _ = self .obs .simulate (change_act )
2526- self .step_obs , reward_real , done_real , _ = self .env .step (change_act )
2527- assert not done_sim
2528- assert not done_real
2525+ self .sim_obs , reward_sim , done_simulate , info_simu = self .obs .simulate (change_act )
2526+ self .step_obs , reward_real , done_step , info_step = self .env .step (change_act )
2527+ assert not done_simulate , f"simulate is done, this should not be"
2528+ assert not done_step , f"step is done, this should not be"
2529+ assert not info_simu ["exception" ]
2530+ assert not info_step ["exception" ]
25292531 assert abs (reward_sim - reward_real ) <= 1e-7
25302532 # Test observations are the same
25312533 if self .sim_obs != self .step_obs :
@@ -2540,8 +2542,12 @@ def test_set_line_status(self):
25402542 # Create set action
25412543 set_act = self .env .action_space ({"set_line_status" : set_status })
25422544 # Simulate & Step
2543- self .sim_obs , _ , _ , _ = self .obs .simulate (set_act )
2544- self .step_obs , _ , _ , _ = self .env .step (set_act )
2545+ self .sim_obs , _ , done_simulate , info_simu = self .obs .simulate (set_act )
2546+ self .step_obs , _ , done_step , info_step = self .env .step (set_act )
2547+ assert not done_simulate , f"simulate is done, this should not be"
2548+ assert not done_step , f"step is done, this should not be"
2549+ assert not info_simu ["exception" ]
2550+ assert not info_step ["exception" ]
25452551 # Test observations are the same
25462552 if self .sim_obs != self .step_obs :
25472553 diff_ , attr_diff = self .sim_obs .where_different (self .step_obs )
@@ -2554,21 +2560,26 @@ def test_change_bus(self):
25542560 "change_bus" : {
25552561 "loads_id" : [0 ],
25562562 "generators_ids" : [0 ],
2557- "lines_or_id" : [0 ],
2563+ # "lines_or_id": [0],
25582564 "lines_ex_id" : [0 ],
25592565 }
25602566 }
25612567 )
25622568 # Simulate & Step
2563- self .sim_obs , _ , _ , _ = self .obs .simulate (change_act )
2564- self .step_obs , _ , _ , _ = self .env .step (change_act )
2569+ self .sim_obs , _ , done_simulate , info_simu = self .obs .simulate (change_act )
2570+ self .step_obs , _ , done_step , info_step = self .env .step (change_act )
2571+ assert not done_simulate , f"simulate is done, this should not be"
2572+ assert not done_step , f"step is done, this should not be"
2573+ assert not info_simu ["exception" ]
2574+ assert not info_step ["exception" ]
2575+
25652576 assert isinstance (
25662577 self .sim_obs , type (self .step_obs )
25672578 ), "sim_obs is not the same type as the step"
25682579 assert isinstance (
25692580 self .step_obs , type (self .sim_obs )
25702581 ), "step is not the same type as the simulation"
2571-
2582+
25722583 # Test observations are the same
25732584 if self .sim_obs != self .step_obs :
25742585 diff_ , attr_diff = self .sim_obs .where_different (self .step_obs )
@@ -2587,14 +2598,18 @@ def test_set_bus(self):
25872598 "set_bus" : {
25882599 "loads_id" : [(0 , new_load_bus )],
25892600 "generators_ids" : [(0 , new_gen_bus )],
2590- "lines_or_id" : [(0 , new_lor_bus )],
2601+ # "lines_or_id": [(0, new_lor_bus)],
25912602 "lines_ex_id" : [(0 , new_lex_bus )],
25922603 }
25932604 }
25942605 )
25952606 # Simulate & Step
2596- self .sim_obs , _ , _ , _ = self .obs .simulate (set_act )
2597- self .step_obs , _ , _ , _ = self .env .step (set_act )
2607+ self .sim_obs , reward_sim , done_simulate , info_simu = self .obs .simulate (set_act )
2608+ self .step_obs , reward_real , done_step , info_step = self .env .step (set_act )
2609+ assert not done_simulate , f"simulate is done, this should not be"
2610+ assert not done_step , f"step is done, this should not be"
2611+ assert not info_simu ["exception" ]
2612+ assert not info_step ["exception" ]
25982613 # Test observations are the same
25992614 if self .sim_obs != self .step_obs :
26002615 diff_ , attr_diff = self .sim_obs .where_different (self .step_obs )
@@ -2610,8 +2625,13 @@ def test_redispatch(self):
26102625 # Create redispatch action
26112626 redisp_act = self .env .action_space ({"redispatch" : [(gen_id , redisp_val )]})
26122627 # Simulate & Step
2613- self .sim_obs , _ , _ , _ = self .obs .simulate (redisp_act )
2614- self .step_obs , _ , _ , _ = self .env .step (redisp_act )
2628+ self .sim_obs , reward_sim , done_simulate , info_simu = self .obs .simulate (redisp_act )
2629+ self .step_obs , reward_real , done_step , info_step = self .env .step (redisp_act )
2630+ assert not done_simulate , f"simulate is done, this should not be"
2631+ assert not done_step , f"step is done, this should not be"
2632+ assert not info_simu ["exception" ]
2633+ assert not info_step ["exception" ]
2634+ assert abs (reward_sim - reward_real ) <= 1e-7
26152635 # Test observations are the same
26162636 if self .sim_obs != self .step_obs :
26172637 diff_ , attr_diff = self .sim_obs .where_different (self .step_obs )
@@ -2817,20 +2837,25 @@ def test_multi_simulate_last_change_bus(self):
28172837 change_bus_act = self .env .action_space (
28182838 {
28192839 "change_bus" : {
2820- "loads_id" : [1 ],
2821- "generators_ids" : [1 ],
2822- "lines_or_id" : [1 ],
2840+ # "loads_id": [1],
2841+ # "generators_ids": [1],
2842+ # "lines_or_id": [1],
28232843 "lines_ex_id" : [1 ],
28242844 }
28252845 }
28262846 )
28272847 actions .append (change_bus_act )
2828-
28292848 # Simulate all actions
28302849 for act in actions :
2831- self .sim_obs , _ , _ , _ = self .obs .simulate (act )
2850+ self .sim_obs , sim_r , sim_d , sim_i = self .obs .simulate (act )
28322851 # Step with last action
2833- self .step_obs , _ , _ , _ = self .env .step (actions [- 1 ])
2852+ self .step_obs , step_r , step_d , step_i = self .env .step (actions [- 1 ])
2853+ assert not sim_d , f"simulate is done, this should not be"
2854+ assert not step_d , f"step is done, this should not be"
2855+ assert not sim_i ["exception" ]
2856+ assert not step_i ["exception" ]
2857+ assert abs (sim_r - step_r ) <= 1e-7
2858+
28342859 # Test observations are the same
28352860 if self .sim_obs != self .step_obs :
28362861 diff_ , attr_diff = self .sim_obs .where_different (self .step_obs )
@@ -2850,9 +2875,9 @@ def test_multi_simulate_last_set_bus(self):
28502875 set_bus_act = self .env .action_space (
28512876 {
28522877 "set_bus" : {
2853- "loads_id" : [(1 , new_load_bus )],
2854- "generators_ids" : [(1 , new_gen_bus )],
2855- "lines_or_id" : [(1 , new_lor_bus )],
2878+ # "loads_id": [(1, new_load_bus)],
2879+ # "generators_ids": [(1, new_gen_bus)],
2880+ # "lines_or_id": [(1, new_lor_bus)],
28562881 "lines_ex_id" : [(1 , new_lex_bus )],
28572882 }
28582883 }
@@ -2861,9 +2886,14 @@ def test_multi_simulate_last_set_bus(self):
28612886
28622887 # Simulate all actions
28632888 for act in actions :
2864- self .sim_obs , _ , _ , _ = self .obs .simulate (act )
2889+ self .sim_obs , sim_r , sim_d , sim_i = self .obs .simulate (act )
28652890 # Step with last action
2866- self .step_obs , _ , _ , _ = self .env .step (actions [- 1 ])
2891+ self .step_obs , step_r , step_d , step_i = self .env .step (actions [- 1 ])
2892+ assert not sim_d , f"simulate is done, this should not be"
2893+ assert not step_d , f"step is done, this should not be"
2894+ assert not sim_i ["exception" ]
2895+ assert not step_i ["exception" ]
2896+ assert abs (sim_r - step_r ) <= 1e-7
28672897 # Test observations are the same
28682898 if self .sim_obs != self .step_obs :
28692899 diff_ , attr_diff = self .sim_obs .where_different (self .step_obs )
0 commit comments