Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne LESOT <[email protected]>
  • Loading branch information
EtienneLt committed Nov 21, 2023
1 parent 4b75b56 commit c914d0b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pypowsybl/network/impl/nad_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def edge_name_displayed(self) -> bool:
def _to_c_parameters(self) -> _pp.NadParameters:
c_parameters = _pp.NadParameters()
c_parameters.edge_name_displayed = self._edge_name_displayed
return c_parameters
return c_parameters
21 changes: 21 additions & 0 deletions pypowsybl/network/impl/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,27 @@ def get_single_line_diagram(self, container_id: str, parameters: SldParameters =
return Svg(svg_and_metadata[0], svg_and_metadata[1])

def write_network_area_diagram_svg(self, svg_file: PathOrStr, voltage_level_ids: Union[str, List[str]] = None,
depth: int = 0, high_nominal_voltage_bound: float = -1,
low_nominal_voltage_bound: float = -1,
edge_name_displayed: bool = False) -> None:
"""
.. deprecated:: 1.1.0
Use :class:`write_network_area_diagram_svg` with `NadParameters` instead.
Create a network area diagram in SVG format and write it to a file.
Args:
svg_file: a svg file path
voltage_level_id: the voltage level ID, center of the diagram (None for the full diagram)
depth: the diagram depth around the voltage level
high_nominal_voltage_bound: high bound to filter voltage level according to nominal voltage
low_nominal_voltage_bound: low bound to filter voltage level according to nominal voltage
edge_name_displayed: if true displays the edge's names
"""
nad_p = NadParameters(edge_name_displayed=edge_name_displayed)
self.write_network_area_diagram(svg_file, voltage_level_ids, depth, high_nominal_voltage_bound,
low_nominal_voltage_bound, nad_p)

def write_network_area_diagram(self, svg_file: PathOrStr, voltage_level_ids: Union[str, List[str]] = None,
depth: int = 0, high_nominal_voltage_bound: float = -1,
low_nominal_voltage_bound: float = -1,
nad_parameters: NadParameters = None) -> None:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,8 @@ def test_sld_nad():
assert re.search('.*<svg.*', sld.svg)
sld = n.get_network_area_diagram('VL6', high_nominal_voltage_bound=50, depth=10)
assert re.search('.*<svg.*', sld.svg)
sld = n.get_network_area_diagram('VL6', nad_parameters=NadParameters(edge_name_displayed=False))
sld = n.get_network_area_diagram('VL6', nad_parameters=NadParameters(edge_name_displayed=True))
assert re.search('.*<svg.*', sld.svg)
with tempfile.TemporaryDirectory() as tmp_dir_name:
test_svg = tmp_dir_name + "test.svg"
n.write_network_area_diagram_svg(test_svg, None)
Expand All @@ -860,7 +861,7 @@ def test_sld_nad():
depth=10)
n.write_network_area_diagram_svg(test_svg, low_nominal_voltage_bound=10, depth=10)
n.write_network_area_diagram_svg(test_svg, high_nominal_voltage_bound=50, depth=10)
n.write_network_area_diagram_svg(test_svg, nad_parameters=NadParameters(edge_name_displayed=False))
n.write_network_area_diagram(test_svg, nad_parameters=NadParameters(edge_name_displayed=True))


def test_nad_displayed_voltage_levels():
Expand Down

0 comments on commit c914d0b

Please sign in to comment.