diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0f5b13447..d51d0e135 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -37,6 +37,8 @@ Change Log this might cause an issue if you install `grid2op[chronix2grid]` for the short thermal - [BREAKING] force key-word arguments in `grid2op.make` except for the first one (env name), see [rte-france#503](https://github.com/rte-france/Grid2Op/issues/503) +- [FIXED] a bug preventing to use storage units in "sim2real" environment (when the + grid for forecast is not the same as the grid for the environment) - [ADDED] a CI to test package can be installed and loaded correctly on windows, macos and line_ex_to_sub_pos for python 3.8, 3.9, 3.10 and 3.11 - [ADDED] possibility to change the "soft_overflow_threshold" in the parameters (like diff --git a/grid2op/Observation/observationSpace.py b/grid2op/Observation/observationSpace.py index db81a8991..afb2c919c 100644 --- a/grid2op/Observation/observationSpace.py +++ b/grid2op/Observation/observationSpace.py @@ -207,7 +207,7 @@ def _create_obs_env(self, env): def _aux_create_backend(self, env, observation_bk_class, observation_bk_kwargs, path_grid_for): if observation_bk_kwargs is None: observation_bk_kwargs = env.backend._my_kwargs - observation_bk_class_used = observation_bk_class.init_grid(env.backend) + observation_bk_class_used = observation_bk_class.init_grid(type(env.backend)) self._backend_obs = observation_bk_class_used(**observation_bk_kwargs) self._backend_obs.set_env_name(env.name) self._backend_obs.load_grid(path_grid_for) diff --git a/grid2op/Space/GridObjects.py b/grid2op/Space/GridObjects.py index 592528a1e..99bbfaa43 100644 --- a/grid2op/Space/GridObjects.py +++ b/grid2op/Space/GridObjects.py @@ -611,6 +611,9 @@ class GridObjects: alertable_line_names = [] # name of each line to produce an alert on # TODO alertable_line_ids = [] + # test + _IS_INIT = False + def __init__(self): """nothing to do when an object of this class is created, the information is held by the class attributes""" pass @@ -663,7 +666,7 @@ def _clear_class_attribute(cls): cls.attr_nan_list_set = set() # class been init - # __is_init = False + cls._IS_INIT = False # name of the objects cls.env_name = "unknown" @@ -1255,8 +1258,9 @@ def _init_class_attr(self, obj=None): setattr(cls, attr_nm, attr) def _compute_pos_big_topo(self): - # TODO move the object attribute as class attribute ! - self._init_class_attr() + # move the object attribute as class attribute ! + if not type(self)._IS_INIT: + self._init_class_attr() cls = type(self) cls._compute_pos_big_topo_cls() @@ -2702,7 +2706,9 @@ def init_grid(cls, gridobj, force=False, extra_name=None, force_module=None): else: # i am the original class from grid2op res_cls._INIT_GRID_CLS = cls - + + res_cls._IS_INIT = True + res_cls._compute_pos_big_topo_cls() res_cls.process_shunt_satic_data() if res_cls.glop_version != grid2op.__version__: