From b5646ddb3bc156d47f4da759f8a31c1280b73898 Mon Sep 17 00:00:00 2001 From: DONNOT Benjamin Date: Wed, 10 Jan 2024 14:13:35 +0100 Subject: [PATCH] fixing broken imports after renaming --- lightsim2grid/tests/test_SecurityAnlysis.py | 30 +++++++++---------- .../tests/test_SecurityAnlysis_cpp.py | 24 +++++++-------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lightsim2grid/tests/test_SecurityAnlysis.py b/lightsim2grid/tests/test_SecurityAnlysis.py index 4927f6f..1ab67da 100644 --- a/lightsim2grid/tests/test_SecurityAnlysis.py +++ b/lightsim2grid/tests/test_SecurityAnlysis.py @@ -11,7 +11,7 @@ import numpy as np import grid2op -from lightsim2grid import SecurityAnalysis +from lightsim2grid import ContingencyAnalysis from lightsim2grid import LightSimBackend import warnings import pdb @@ -28,10 +28,10 @@ def tearDown(self) -> None: return super().tearDown() def test_can_create(self): - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) def test_clear(self): - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) # add simple contingencies sa.add_multiple_contingencies(0, 1, 2, 3) @@ -46,7 +46,7 @@ def test_clear(self): assert len(sa._contingency_order) == 0 def test_add_single_contingency(self): - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) with self.assertRaises(RuntimeError): sa.add_single_contingency("toto") with self.assertRaises(RuntimeError): @@ -64,7 +64,7 @@ def test_add_single_contingency(self): assert len(sa._contingency_order) == 4 def test_add_multiple_contingencies(self): - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) # add simple contingencies sa.add_multiple_contingencies(0, 1, 2, 3) all_conts = sa.computer.my_defaults() @@ -91,7 +91,7 @@ def test_add_multiple_contingencies(self): assert len(sa._contingency_order) == 4 def test_add_all_n1_contingencies(self): - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) sa.add_all_n1_contingencies() all_conts = sa.computer.my_defaults() assert len(all_conts) == self.env.n_line @@ -100,7 +100,7 @@ def test_add_all_n1_contingencies(self): def test_get_flows_simple(self): """test the get_flows method in the most simplest way: ask for all contingencies, contingencies are given in the right order""" - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) sa.add_multiple_contingencies(0, 1, 2) res_p, res_a, res_v = sa.get_flows() assert res_a.shape == (3, self.env.n_line) @@ -111,7 +111,7 @@ def test_get_flows_simple(self): def test_get_flows_1(self): """test the get_flows method: ask for all contingencies , contingencies are NOT given in the right order""" - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) sa.add_multiple_contingencies(0, 2, 1) res_p, res_a, res_v = sa.get_flows() assert res_a.shape == (3, self.env.n_line) @@ -122,7 +122,7 @@ def test_get_flows_1(self): def test_get_flows_2(self): """test the get_flows method: don't ask for all contingencies (same order as given), contingencies are given in the right order""" - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) sa.add_multiple_contingencies(0, 1, 2) res_p, res_a, res_v = sa.get_flows(0, 1) assert res_a.shape == (2, self.env.n_line) @@ -132,7 +132,7 @@ def test_get_flows_2(self): def test_get_flows_3(self): """test the get_flows method in the most simplest way: not all contingencies (not same order as given), contingencies are given in the right order""" - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) sa.add_multiple_contingencies(0, 1, 2) res_p, res_a, res_v = sa.get_flows(0, 2) assert res_a.shape == (2, self.env.n_line) @@ -142,7 +142,7 @@ def test_get_flows_3(self): def test_get_flows_4(self): """test the get_flows method: don't ask for all contingencies (same order as given), contingencies are NOT given in the right order""" - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) sa.add_multiple_contingencies(0, 2, 1) res_p, res_a, res_v = sa.get_flows(0, 2) assert res_a.shape == (2, self.env.n_line) @@ -152,7 +152,7 @@ def test_get_flows_4(self): def test_get_flows_5(self): """test the get_flows method in the most simplest way: not all contingencies (not same order as given), contingencies are NOT given in the right order""" - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) sa.add_multiple_contingencies(0, 2, 1) res_p, res_a, res_v = sa.get_flows(0, 1) assert res_a.shape == (2, self.env.n_line) @@ -161,7 +161,7 @@ def test_get_flows_5(self): def test_get_flows_multiple(self): """test the get_flows function when multiple contingencies""" - sa = SecurityAnalysis(self.env) + sa = ContingencyAnalysis(self.env) sa.add_multiple_contingencies(0, [0, 4], [5, 7], 4) # everything @@ -197,11 +197,11 @@ def test_get_flows_multiple(self): def test_change_injection(self): """test the capacity of the things to handle different steps""" - sa1 = SecurityAnalysis(self.env) + sa1 = ContingencyAnalysis(self.env) conts = [0, [0, 4], [5, 7], 4] sa1.add_multiple_contingencies(*conts) self.env.reset() - sa2 = SecurityAnalysis(self.env) + sa2 = ContingencyAnalysis(self.env) sa2.add_multiple_contingencies(*conts) res_p1, res_a1, res_v1 = sa1.get_flows() diff --git a/lightsim2grid/tests/test_SecurityAnlysis_cpp.py b/lightsim2grid/tests/test_SecurityAnlysis_cpp.py index bbf73ae..15de108 100644 --- a/lightsim2grid/tests/test_SecurityAnlysis_cpp.py +++ b/lightsim2grid/tests/test_SecurityAnlysis_cpp.py @@ -10,7 +10,7 @@ import numpy as np import grid2op -from lightsim2grid_cpp import SecurityAnalysisCPP +from lightsim2grid_cpp import ContingencyAnalysisCPP from lightsim2grid import LightSimBackend import warnings import pdb @@ -29,11 +29,11 @@ def tearDown(self) -> None: return super().tearDown() def test_can_create(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) assert len(SA.my_defaults()) == 0 def test_add_n1(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) SA.add_n1(0) all_def = SA.my_defaults() assert len(all_def) == 1 @@ -64,7 +64,7 @@ def test_add_n1(self): SA.add_n1(20) def test_add_multiple_n1(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) SA.add_multiple_n1([0]) all_def = SA.my_defaults() assert len(all_def) == 1 @@ -99,7 +99,7 @@ def test_add_multiple_n1(self): SA.add_multiple_n1([20]) def test_add_nk(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) SA.add_nk([0]) all_def = SA.my_defaults() assert len(all_def) == 1 @@ -132,13 +132,13 @@ def test_add_nk(self): SA.add_nk([20]) def test_add_all_n1(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) SA.add_all_n1() all_def = SA.my_defaults() assert len(all_def) == self.env.n_line def test_remove_n1(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) SA.add_all_n1() assert SA.remove_n1(0) # this should remove it and return true (because the removing is a success) all_def = SA.my_defaults() @@ -148,7 +148,7 @@ def test_remove_n1(self): assert len(all_def) == self.env.n_line - 1 def test_clear(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) SA.add_all_n1() all_def = SA.my_defaults() assert len(all_def) == self.env.n_line @@ -157,7 +157,7 @@ def test_clear(self): assert len(all_def) == 0 def test_remove_multiple_n1(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) SA.add_all_n1() nb_removed = SA.remove_multiple_n1([0, 1, 2]) assert nb_removed == 3 @@ -169,7 +169,7 @@ def test_remove_multiple_n1(self): assert len(all_def) == self.env.n_line - 5 def test_remove_nk(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) SA.add_nk([0, 1]) SA.add_nk([0, 2]) SA.add_nk([0, 3]) @@ -188,7 +188,7 @@ def test_remove_nk(self): assert len(all_def) == 2 def test_compute(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) lid_cont = [0, 1, 2, 3] nb_sub = self.env.n_sub SA.add_multiple_n1(lid_cont) @@ -207,7 +207,7 @@ def test_compute(self): assert np.max(np.abs(res_flows[cont_id] - sim_obs.a_or*1e-3)) <= 1e-6, f"error in flows when disconnecting line {l_id} (contingency nb {cont_id})" def test_compute_nonconnected_graph(self): - SA = SecurityAnalysisCPP(self.env.backend._grid) + SA = ContingencyAnalysisCPP(self.env.backend._grid) lid_cont = [17, 18, 19] # 17 is ok, 18 lead to divergence, i need to check then that 19 is correct (no divergence) nb_sub = self.env.n_sub SA.add_multiple_n1(lid_cont)