From e0f300fefd0fb097bc37a518918e1230054e533b Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Sun, 12 Nov 2023 23:42:20 +0100 Subject: [PATCH] Fix Signed-off-by: Geoffroy Jamgotchian --- docs/user_guide/network.rst | 10 ++++++++-- pypowsybl/_pypowsybl.pyi | 4 ++-- tests/test_network.py | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/user_guide/network.rst b/docs/user_guide/network.rst index d78b62523a..ae54346d41 100644 --- a/docs/user_guide/network.rst +++ b/docs/user_guide/network.rst @@ -68,13 +68,19 @@ Networks can be written to the filesystem, using one of the available export for .. code-block:: python - network.dump('network.xiidm', format='XIIDM') + network.save('network.xiidm', format='XIIDM') You can also serialize networks to a string: .. code-block:: python - xiidm_str = network.dump_to_string('XIIDM') + xiidm_str = network.save_to_string('XIIDM') + +And also to a zip file as a (io.BytesIO) binary buffer. + +.. code-block:: python + + zipped_xiidm = network.save_to_binary_buffer('XIIDM') The supported formats are: diff --git a/pypowsybl/_pypowsybl.pyi b/pypowsybl/_pypowsybl.pyi index 495e360913..d29d874df6 100644 --- a/pypowsybl/_pypowsybl.pyi +++ b/pypowsybl/_pypowsybl.pyi @@ -553,8 +553,8 @@ def get_extensions_names() -> List[str]: ... def get_extensions_information() -> SeriesArray: ... def create_security_analysis() -> JavaHandle: ... def create_sensitivity_analysis() -> JavaHandle: ... -def dump_network(network: JavaHandle, file: str, format: str, parameters: Dict[str,str], report: Optional[JavaHandle]) -> None: ... -def dump_network_to_string(network: JavaHandle, format: str, parameters: Dict[str,str], report: Optional[JavaHandle]) -> str: ... +def save_network(network: JavaHandle, file: str, format: str, parameters: Dict[str,str], report: Optional[JavaHandle]) -> None: ... +def save_network_to_string(network: JavaHandle, format: str, parameters: Dict[str,str], report: Optional[JavaHandle]) -> str: ... def get_branch_flows_sensitivity_matrix(sensitivity_analysis_result_context: JavaHandle, matrix_id: str, contingency_id: str) -> Matrix: ... def get_branch_results(result: JavaHandle) -> SeriesArray: ... def get_bus_breaker_view_buses(network: JavaHandle, voltage_level: str) -> SeriesArray: ... diff --git a/tests/test_network.py b/tests/test_network.py index bf2bcb1bc0..9445ec84b9 100644 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -124,7 +124,7 @@ def test_save_matpower(): assert 'test.mat' in file_names n2 = pp.network.load(mat_file) assert isinstance(n2, pp.network.Network) - # assert n2.dump_to_string() == n.dump_to_string() # problem import/export matpower + # assert n2.save_to_string() == n.save_to_string() # problem import/export matpower def test_save_ucte():