@@ -1844,8 +1844,9 @@ def get_action_to_set(self) -> "grid2op.Action.CompleteAction":
18441844 p_s , q_s , sh_v , bus_s = self .shunt_info ()
18451845 dict_ ["shunt" ] = {"shunt_bus" : bus_s }
18461846 if (bus_s >= 1 ).sum ():
1847- p_s *= (self ._sh_vnkv / sh_v ) ** 2
1848- q_s *= (self ._sh_vnkv / sh_v ) ** 2
1847+ sh_conn = bus_s > 0
1848+ p_s [sh_conn ] *= (self ._sh_vnkv [sh_conn ] / sh_v [sh_conn ]) ** 2
1849+ q_s [sh_conn ] *= (self ._sh_vnkv [sh_conn ] / sh_v [sh_conn ]) ** 2
18491850 p_s [bus_s == - 1 ] = np .NaN
18501851 q_s [bus_s == - 1 ] = np .NaN
18511852 dict_ ["shunt" ]["shunt_p" ] = p_s
@@ -1944,21 +1945,28 @@ def assert_grid_correct(self) -> None:
19441945 from grid2op .Action import CompleteAction
19451946 from grid2op .Action ._backendAction import _BackendAction
19461947
1947- if self ._missing_two_busbars_support_info :
1948- warnings .warn ("The backend implementation you are using is probably too old to take advantage of the "
1949- "new feature added in grid2op 1.10.0: the possibility "
1950- "to have more than 2 busbars per substations (or not). "
1951- "To silence this warning, you can modify the `load_grid` implementation "
1952- "of your backend and either call:\n "
1953- "- self.can_handle_more_than_2_busbar if the current implementation "
1954- " can handle more than 2 busbsars OR\n "
1955- "- self.cannot_handle_more_than_2_busbar if not."
1956- "\n And of course, ideally, if the current implementation "
1957- "of your backend cannot "
1958- "handle more than 2 busbars per substation, then change it :-)\n "
1959- "Your backend will behave as if it did not support it." )
1948+ if hasattr (self , "_missing_two_busbars_support_info" ):
1949+ if self ._missing_two_busbars_support_info :
1950+ warnings .warn ("The backend implementation you are using is probably too old to take advantage of the "
1951+ "new feature added in grid2op 1.10.0: the possibility "
1952+ "to have more than 2 busbars per substations (or not). "
1953+ "To silence this warning, you can modify the `load_grid` implementation "
1954+ "of your backend and either call:\n "
1955+ "- self.can_handle_more_than_2_busbar if the current implementation "
1956+ " can handle more than 2 busbsars OR\n "
1957+ "- self.cannot_handle_more_than_2_busbar if not."
1958+ "\n And of course, ideally, if the current implementation "
1959+ "of your backend cannot "
1960+ "handle more than 2 busbars per substation, then change it :-)\n "
1961+ "Your backend will behave as if it did not support it." )
1962+ self ._missing_two_busbars_support_info = False
1963+ self .n_busbar_per_sub = DEFAULT_N_BUSBAR_PER_SUB
1964+ else :
19601965 self ._missing_two_busbars_support_info = False
19611966 self .n_busbar_per_sub = DEFAULT_N_BUSBAR_PER_SUB
1967+ warnings .warn ("Your backend is missing the `_missing_two_busbars_support_info` "
1968+ "attribute. This is known issue in lightims2grid <= 0.7.5. Please "
1969+ "upgrade your backend. This will raise an error in the future." )
19621970
19631971 orig_type = type (self )
19641972 if orig_type .my_bk_act_class is None :
0 commit comments