Skip to content

Commit

Permalink
fixing some broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Oct 23, 2023
1 parent 82f9cde commit 93f90dd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lightsim2grid/lightSimBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions lightsim2grid/tests/test_backend_pypowsybl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 5 additions & 11 deletions lightsim2grid/tests/test_basic_backend_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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` :-(")

Expand Down
3 changes: 1 addition & 2 deletions src/GridModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ 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_;

// copy the powersystem representation
// 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_;
Expand Down
2 changes: 1 addition & 1 deletion src/GridModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GridModel : public DataGeneric
int, // version major
int, // version medium
int, // version minor
std::vector<int>, // ls_to_pp
std::vector<int>, // ls_to_orig
real_type, // init_vm_pu
real_type, //sn_mva
std::vector<real_type>, // bus_vn_kv
Expand Down

0 comments on commit 93f90dd

Please sign in to comment.