Skip to content

Commit

Permalink
Add: ClassAttribute integration for AllowDetachment
Browse files Browse the repository at this point in the history
  • Loading branch information
DEUCE1957 committed Nov 6, 2024
1 parent 25c3aac commit 5981964
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions grid2op/Space/GridObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2034,17 +2034,9 @@ def assert_grid_correct_cls(cls):
# TODO n_busbar_per_sub different num per substations
if isinstance(cls.n_busbar_per_sub, (int, dt_int, np.int32, np.int64)):
cls.n_busbar_per_sub = dt_int(cls.n_busbar_per_sub)
# np.full(cls.n_sub,
# fill_value=cls.n_busbar_per_sub,
# dtype=dt_int)
else:
# cls.n_busbar_per_sub = np.array(cls.n_busbar_per_sub)
# cls.n_busbar_per_sub = cls.n_busbar_per_sub.astype(dt_int)
raise EnvError("Grid2op cannot handle a different number of busbar per substations at the moment.")

# if cls.n_busbar_per_sub != int(cls.n_busbar_per_sub):
# raise EnvError(f"`n_busbar_per_sub` should be convertible to an integer, found {cls.n_busbar_per_sub}")
# cls.n_busbar_per_sub = int(cls.n_busbar_per_sub)
if (cls.n_busbar_per_sub < 1).any():
raise EnvError(f"`n_busbar_per_sub` should be >= 1 found {cls.n_busbar_per_sub}")

Expand Down Expand Up @@ -3931,6 +3923,8 @@ def _make_cls_dict(cls, res, as_list=True, copy_=True, _topo_vect_only=False):
res["name_shunt"] = None
res["shunt_to_subid"] = None


save_to_dict(res, cls, "allow_detachment", bool, copy_)

if not _topo_vect_only:
# all the attributes bellow are not needed for the "first call"
Expand Down Expand Up @@ -4411,7 +4405,7 @@ class res(GridObjects):
cls.alertable_line_names = []
cls.alertable_line_ids = []

# Shedding
# Detachment of Loads / Generators
if 'allow_detachment' in dict_:
cls.allow_detachment = bool(dict_["allow_detachment"])
else: # Compatibility for older versions
Expand Down Expand Up @@ -4976,7 +4970,8 @@ class {cls.__name__}({cls._INIT_GRID_CLS.__name__}):
sub_info = {sub_info_str}
dim_topo = {cls.dim_topo}
allow_detachment = {cls.allow_detachment}
# to which substation is connected each element
load_to_subid = {load_to_subid_str}
gen_to_subid = {gen_to_subid_str}
Expand Down

0 comments on commit 5981964

Please sign in to comment.