diff --git a/lightsim2grid/lightSimBackend.py b/lightsim2grid/lightSimBackend.py index 461b13d..60a2067 100644 --- a/lightsim2grid/lightSimBackend.py +++ b/lightsim2grid/lightSimBackend.py @@ -513,14 +513,13 @@ def make_complete_path(path, filename): for i in range(self.__nb_bus_before): self._grid.deactivate_bus(i + self.__nb_bus_before) new_orig_to_ls = np.concatenate((orig_to_ls, - np.zeros(orig_to_ls.shape[0], dtype=orig_to_ls.dtype) + self.__nb_bus_before) + orig_to_ls + self.__nb_bus_before) ) self._grid._orig_to_ls = new_orig_to_ls self.nb_bus_total = len(self._grid.get_buses()) # and now things needed by the backend (legacy) self._big_topo_to_obj = [(None, None) for _ in range(type(self).dim_topo)] - self._aux_finish_setup_after_reading() self.prod_pu_to_kv = 1.0 * self._grid.get_buses()[[el.bus_id for el in self._grid.get_generators()]] self.prod_pu_to_kv = self.prod_pu_to_kv.astype(dt_float) @@ -530,6 +529,7 @@ def make_complete_path(path, filename): bus_vn_kv = np.array(self._grid.get_buses()) shunt_bus_id = np.array([el.bus_id for el in self._grid.get_shunts()]) self._sh_vnkv = bus_vn_kv[shunt_bus_id] + self._aux_finish_setup_after_reading() def _aux_setup_right_after_grid_init(self): self._handle_turnedoff_pv() diff --git a/lightsim2grid/tests/test_backend_pypowsybl.py b/lightsim2grid/tests/test_backend_pypowsybl.py index 4cc8528..bce90c2 100644 --- a/lightsim2grid/tests/test_backend_pypowsybl.py +++ b/lightsim2grid/tests/test_backend_pypowsybl.py @@ -114,9 +114,9 @@ def get_casefile(self): return "grid.xiidm" def make_backend(self, detailed_infos_for_cascading_failures=False): - return LightSimBackend(loader_method="pypowsybl", - loader_kwargs=_aux_get_loader_kwargs_storage(), - detailed_infos_for_cascading_failures=detailed_infos_for_cascading_failures) + return LightSimBackend(loader_method="pypowsybl", + loader_kwargs=_aux_get_loader_kwargs_storage(), + detailed_infos_for_cascading_failures=detailed_infos_for_cascading_failures) # # add test of grid2op for the backend based on pypowsybl # def this_make_backend(self, detailed_infos_for_cascading_failures=False): diff --git a/lightsim2grid/tests/test_basic_backend_api.py b/lightsim2grid/tests/test_basic_backend_api.py index c404bad..08a8dde 100644 --- a/lightsim2grid/tests/test_basic_backend_api.py +++ b/lightsim2grid/tests/test_basic_backend_api.py @@ -17,17 +17,11 @@ from lightsim2grid import LightSimBackend if CAN_PERFORM_THESE: - def this_make_backend(self, detailed_infos_for_cascading_failures=False): - return LightSimBackend( - detailed_infos_for_cascading_failures=detailed_infos_for_cascading_failures - ) - add_name_cls = "test_LightSimBackend" - - res = create_test_suite(make_backend_fun=this_make_backend, - add_name_cls=add_name_cls, - add_to_module=__name__, - extended_test=False, # for now keep `extended_test=False` until all problems are solved - ) + from grid2op.tests.aaa_test_backend_interface import AAATestBackendAPI + class TestBackendAPI_LSTester(AAATestBackendAPI, unittest.TestCase): + def make_backend(self, detailed_infos_for_cascading_failures=False): + return LightSimBackend(detailed_infos_for_cascading_failures=detailed_infos_for_cascading_failures) + else: print("Have you installed grid2op in dev / editable mode ? We cannot make the `create_test_suite` :-(") diff --git a/src/GridModel.cpp b/src/GridModel.cpp index 31b0135..2ee2fbb 100644 --- a/src/GridModel.cpp +++ b/src/GridModel.cpp @@ -14,8 +14,6 @@ GridModel::GridModel(const GridModel & other) { reset(true, true, true); - set_ls_to_orig(other._ls_to_orig); // set also orig_to_ls - init_vm_pu_ = other.init_vm_pu_; sn_mva_ = other.sn_mva_; @@ -23,6 +21,7 @@ GridModel::GridModel(const GridModel & other) // 1. bus bus_vn_kv_ = other.bus_vn_kv_; bus_status_ = other.bus_status_; + set_ls_to_orig(other._ls_to_orig); // set also orig_to_ls // 2. powerline powerlines_ = other.powerlines_; diff --git a/src/GridModel.h b/src/GridModel.h index 751a960..85b384f 100644 --- a/src/GridModel.h +++ b/src/GridModel.h @@ -49,7 +49,7 @@ class GridModel : public DataGeneric int, // version major int, // version medium int, // version minor - std::vector, // ls_to_pp + std::vector, // ls_to_orig real_type, // init_vm_pu real_type, //sn_mva std::vector, // bus_vn_kv