Skip to content

Commit

Permalink
still working on making tests pass with new more concise implementation
Browse files Browse the repository at this point in the history
Signed-off-by: DONNOT Benjamin <[email protected]>
  • Loading branch information
BDonnot committed Nov 25, 2024
1 parent dbba375 commit 09d1a65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ Native multi agents support:
does not have shunt information but there are not shunts on the grid.
- [IMPROVED] consistency of `MultiMixEnv` in case of automatic_classes (only one
class is generated for all mixes)

- [IMRPOVED] handling of disconnected elements in the backend no more
raise error. The base `Backend` class does that.

[1.10.4] - 2024-10-15
-------------------------
- [FIXED] new pypi link (no change in code)
Expand Down
11 changes: 4 additions & 7 deletions grid2op/Backend/pandaPowerBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,7 @@ def apply_action(self, backendAction: Union["grid2op.Action._backendAction._Back
self._grid.storage.loc[stor_bus.changed & deactivated, "in_service"] = False
self._grid.storage.loc[stor_bus.changed & ~deactivated, "in_service"] = True
self._grid.storage["bus"] = new_bus_num
self._topo_vect[cls.storage_pos_topo_vect[stor_bus.changed]] = new_bus_id
self._topo_vect[
cls.storage_pos_topo_vect[deact_and_changed]
] = -1


if type(backendAction).shunts_data_available:
shunt_p, shunt_q, shunt_bus = shunts__

Expand All @@ -939,6 +935,8 @@ def apply_action(self, backendAction: Union["grid2op.Action._backendAction._Back
if type_obj is not None:
# storage unit are handled elsewhere
self._type_to_bus_set[type_obj](new_bus, id_el_backend, id_topo)

self._topo_vect.flags.writeable = False

def _apply_load_bus(self, new_bus, id_el_backend, id_topo):
new_bus_backend = type(self).local_bus_to_global_int(
Expand Down Expand Up @@ -1190,7 +1188,6 @@ def runpf(self, is_dc : bool=False) -> Tuple[bool, Union[Exception, None]]:
if not self._grid.converged:
raise pp.powerflow.LoadflowNotConverged("Divergence without specific reason (self._grid.converged is False)")
self.div_exception = None
self._get_topo_vect() # do that after (maybe useless)
return True, None

except pp.powerflow.LoadflowNotConverged as exc_:
Expand Down Expand Up @@ -1427,7 +1424,7 @@ def _get_topo_vect(self):
self._topo_vect[cls.gen_pos_topo_vect[~gen_status]] = -1
# storage
if cls.n_storage:
storage_status = 1 * self._grid.storage["in_service"].values
storage_status = self._grid.storage["in_service"].values
self._topo_vect[cls.storage_pos_topo_vect] = cls.global_bus_to_local(self._grid.storage["bus"].values, cls.storage_to_subid)
self._topo_vect[cls.storage_pos_topo_vect[~storage_status]] = -1
self._topo_vect.flags.writeable = False
Expand Down
2 changes: 1 addition & 1 deletion grid2op/tests/aaa_test_backend_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ def _aux_check_el_generic(self, backend, busbar_id,
key_: val # move the line
}})
bk_act = type(backend).my_bk_act_class()
bk_act += action
bk_act += action # "compile" all the user action into one single action sent to the backend
backend.apply_action(bk_act) # apply the action
res = backend.runpf(is_dc=False)
assert res[0], f"Your backend diverged in AC after setting a {el_nm} on busbar {busbar_id}, error was {res[1]}"
Expand Down

0 comments on commit 09d1a65

Please sign in to comment.