@@ -290,8 +290,11 @@ def save_to_binary_buffer(self, format: str = 'XIIDM', parameters: ParamsDict =
290290 None if report_node is None else report_node ._report_node )) # pylint: disable=protected-access
291291
292292 def reduce (self , v_min : float = 0 , v_max : float = sys .float_info .max , ids : Optional [List [str ]] = None ,
293- vl_depths : tuple = () , with_dangling_lines : bool = False ) -> None :
293+ vl_depths : Optional [ List [ tuple ]] = None , with_dangling_lines : bool = False ) -> None :
294294 """
295+ .. deprecated:: 1.14.0
296+ Use :meth:`reduce_by_voltage_range`, :meth:`reduce_by_ids` or :meth:`reduce_by_ids_and_depths` instead depending on your use case.
297+
295298 Reduce to a smaller network according to the following parameters
296299
297300 :param v_min: minimum voltage of the voltage levels kept after reducing
@@ -300,15 +303,76 @@ def reduce(self, v_min: float = 0, v_max: float = sys.float_info.max, ids: Optio
300303 :param vl_depths: depth around voltage levels which are indicated by their id, that will be kept
301304 :param with_dangling_lines: keeping the dangling lines
302305 """
306+ warnings .warn ("reduce is deprecated, use `reduce_by_voltage_range`, `reduce_by_ids` or `reduce_by_ids_and_depths` instead depending on your use case" , DeprecationWarning )
303307 if ids is None :
304308 ids = []
305309 vls = []
306310 depths = []
311+ if vl_depths is None :
312+ vl_depths = []
307313 for v in vl_depths :
308314 vls .append (v [0 ])
309315 depths .append (v [1 ])
310316 _pp .reduce_network (self ._handle , v_min , v_max , ids , vls , depths , with_dangling_lines )
311317
318+ def reduce_by_voltage_range (self , v_min : float = 0 , v_max : float = sys .float_info .max , with_dangling_lines : bool = False ) -> None :
319+ """
320+ Reduce to a smaller network (only keeping all elements whose nominal voltage is in the specified voltage range)
321+
322+ :param v_min: minimum voltage of the voltage levels kept after reducing
323+ :param v_max: voltage maximum of the voltage levels kept after reducing
324+ :param with_dangling_lines: whether dangling lines should be created to replace lines cut at the boundary of reduction
325+
326+ Example:
327+
328+ .. code-block:: python
329+
330+ network.reduce_by_voltage_range(v_min=90, v_max=250, with_dangling_lines=True)
331+
332+ will only keep elements of voltage level between 90 and 250kV, replacing the lines cut at the boundary by dangling lines.
333+ """
334+ _pp .reduce_network (self ._handle , v_min = v_min , v_max = v_max , ids = [], vls = [], depths = [], with_dangling_lines = with_dangling_lines )
335+
336+ def reduce_by_ids (self , ids : List [str ], with_dangling_lines : bool = False ) -> None :
337+ """
338+ Reduce to a smaller network (only keeping voltage levels whose id is in the specified list)
339+
340+ :param ids: list of the voltage level ids that should be kept in the reduced network
341+ :param with_dangling_lines: whether dangling lines should be created to replace lines cut at the boundary of reduction
342+
343+ Example:
344+
345+ .. code-block:: python
346+
347+ network.reduce_by_ids(ids=["VL1", "VL2"])
348+
349+ will only keep voltage levels VL1 and VL2 and all network elements between them.
350+ """
351+ _pp .reduce_network (self ._handle , v_min = 0 , v_max = sys .float_info .max , ids = ids , vls = [], depths = [], with_dangling_lines = with_dangling_lines )
352+
353+ def reduce_by_ids_and_depths (self , vl_depths : List [tuple [str , int ]], with_dangling_lines : bool = False ) -> None :
354+ """
355+ Reduce to a smaller network (keeping the specified voltage levels with all respective neighbours at most at the specified depth).
356+
357+ :param vl_depths: list of the voltage level ids that should be kept in the reduced network
358+ :param with_dangling_lines: whether dangling lines should be created to replace lines cut at the boundary of reduction
359+
360+ Example:
361+
362+ .. code-block:: python
363+
364+ network.reduce_by_ids_and_depths(vl_depths=[("VL1", 1), ("VL25", 3)])
365+
366+ will only keep voltage levels VL1 and its neighbours, and VL25 with all elements around it with at most 3 connections between them.
367+ """
368+ vls = []
369+ depths = []
370+ for v in vl_depths :
371+ vls .append (v [0 ])
372+ depths .append (v [1 ])
373+ _pp .reduce_network (self ._handle , v_min = 0 , v_max = sys .float_info .max , ids = [], vls = vls , depths = depths , with_dangling_lines = with_dangling_lines )
374+
375+
312376 def write_single_line_diagram_svg (self , container_id : str , svg_file : PathOrStr , metadata_file : Optional [PathOrStr ] = None ,
313377 parameters : Optional [SldParameters ] = None , sld_profile : Optional [SldProfile ] = None ) -> None :
314378 """
0 commit comments