Skip to content

Commit

Permalink
add missing deprecated warnings (#680)
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
  • Loading branch information
EtienneLt authored and geofjamg committed Dec 10, 2023
1 parent 9b31f1f commit 75f3721
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
15 changes: 12 additions & 3 deletions pypowsybl/network/impl/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ def disconnect(self, id: str) -> bool:
def dump(self, file: PathOrStr, format: str = 'XIIDM', parameters: ParamsDict = None,
reporter: Reporter = None) -> None:
"""
Deprecated, use :meth:`save` instead.
.. deprecated:: 1.1.0
Use :meth:`save` instead.
"""
warnings.warn("dump is deprecated, use save instead", DeprecationWarning)
self.save(file, format, parameters, reporter)

def save(self, file: PathOrStr, format: str = 'XIIDM', parameters: ParamsDict = None,
Expand Down Expand Up @@ -160,8 +162,10 @@ def save(self, file: PathOrStr, format: str = 'XIIDM', parameters: ParamsDict =

def dump_to_string(self, format: str = 'XIIDM', parameters: ParamsDict = None, reporter: Reporter = None) -> str:
"""
Deprecated, use :meth:`save_to_string` instead.
.. deprecated:: 1.1.0
Use :meth:`save_to_string` instead.
"""
warnings.warn("dump_to_string is deprecated, use save_to_string instead", DeprecationWarning)
return self.save_to_string(format, parameters, reporter)

def save_to_string(self, format: str = 'XIIDM', parameters: ParamsDict = None, reporter: Reporter = None) -> str:
Expand Down Expand Up @@ -3239,8 +3243,9 @@ def get_variant_ids(self) -> List[str]:

def get_current_limits(self, all_attributes: bool = False, attributes: List[str] = None) -> DataFrame:
"""
.. deprecated::
Use :meth:`get_operational_limits` instead.
Get the list of all current limits on the network paired with their branch id.
get_current_limits is deprecated, use get_operational_limits instead
Args:
all_attributes (bool, optional): flag for including all attributes in the dataframe, default is false
Expand Down Expand Up @@ -4455,6 +4460,10 @@ def get_extensions(self, extension_name: str, table_name: str = "") -> DataFrame
_pp.create_network_elements_extension_series_array(self._handle, extension_name, table_name))

def get_extension(self, extension_name: str) -> DataFrame:
"""
.. deprecated::
Use :meth:`get_extensions` instead.
"""
warnings.warn("get_extension is deprecated, use get_extensions instead", DeprecationWarning)
return self.get_extensions(extension_name)

Expand Down
3 changes: 3 additions & 0 deletions pypowsybl/sensitivity/impl/ac_sensitivity_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
#
import warnings
from typing import List, Union
from pypowsybl import _pypowsybl
from pypowsybl.network import Network
Expand Down Expand Up @@ -35,6 +36,8 @@ def set_bus_voltage_factor_matrix(self, bus_ids: List[str], target_voltage_ids:
bus_ids: IDs of buses for which voltage sensitivities should be computed
target_voltage_ids: IDs of regulating equipments to which we should compute sensitivities
"""
warnings.warn("set_bus_voltage_factor_matrix is deprecated, use add_bus_voltage_factor_matrix instead",
DeprecationWarning)
self.add_bus_voltage_factor_matrix(bus_ids, target_voltage_ids)

def add_bus_voltage_factor_matrix(self, bus_ids: List[str], target_voltage_ids: List[str], matrix_id: str = DEFAULT_MATRIX_ID) -> None:
Expand Down
11 changes: 9 additions & 2 deletions pypowsybl/sensitivity/impl/ac_sensitivity_analysis_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
#
import warnings
from typing import Dict, List, Optional
import pandas as pd
from pypowsybl import _pypowsybl
Expand All @@ -25,7 +26,8 @@ def __init__(self,
function_data_frame_index: Dict[str, List[str]]):
DcSensitivityAnalysisResult.__init__(self, result_context_ptr, functions_ids, function_data_frame_index)

def get_bus_voltages_sensitivity_matrix(self, matrix_id: str = DEFAULT_MATRIX_ID, contingency_id: str = None) -> Optional[pd.DataFrame]:
def get_bus_voltages_sensitivity_matrix(self, matrix_id: str = DEFAULT_MATRIX_ID, contingency_id: str = None) -> \
Optional[pd.DataFrame]:
"""
.. deprecated:: 1.1.0
Use :meth:`get_sensitivity_matrix` instead.
Expand All @@ -37,9 +39,12 @@ def get_bus_voltages_sensitivity_matrix(self, matrix_id: str = DEFAULT_MATRIX_ID
Returns:
the matrix of sensitivities
"""
warnings.warn("get_bus_voltages_sensitivity_matrix is deprecated, use get_sensitivity_matrix instead",
DeprecationWarning)
return self.get_sensitivity_matrix(matrix_id, contingency_id)

def get_reference_voltages(self, matrix_id: str = DEFAULT_MATRIX_ID, contingency_id: str = None) -> Optional[pd.DataFrame]:
def get_reference_voltages(self, matrix_id: str = DEFAULT_MATRIX_ID, contingency_id: str = None) -> Optional[
pd.DataFrame]:
"""
.. deprecated:: 1.1.0
Use :meth:`get_reference_matrix` instead.
Expand All @@ -52,4 +57,6 @@ def get_reference_voltages(self, matrix_id: str = DEFAULT_MATRIX_ID, contingency
Returns:
the values of bus voltages
"""
warnings.warn("get_reference_voltages is deprecated, use get_reference_matrix instead",
DeprecationWarning)
return self.get_reference_matrix(matrix_id, contingency_id, 'reference_voltages')
5 changes: 5 additions & 0 deletions pypowsybl/sensitivity/impl/dc_sensitivity_analysis_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
#
import warnings
from typing import Dict, List, Optional
import pandas as pd
from pypowsybl import _pypowsybl
Expand Down Expand Up @@ -40,6 +41,8 @@ def get_branch_flows_sensitivity_matrix(self, matrix_id: str = DEFAULT_MATRIX_ID
Returns:
the matrix of branch flows sensitivities
"""
warnings.warn("get_branch_flows_sensitivity_matrix is deprecated, use get_sensitivity_matrix instead",
DeprecationWarning)
return self.get_sensitivity_matrix(matrix_id, contingency_id)

def get_reference_flows(self, matrix_id: str = DEFAULT_MATRIX_ID, contingency_id: str = None) -> Optional[pd.DataFrame]:
Expand All @@ -55,4 +58,6 @@ def get_reference_flows(self, matrix_id: str = DEFAULT_MATRIX_ID, contingency_id
Returns:
the branches active power flows
"""
warnings.warn("get_reference_flows is deprecated, use get_reference_matrix instead",
DeprecationWarning)
return self.get_reference_matrix(matrix_id, contingency_id, 'reference_flows')
4 changes: 4 additions & 0 deletions pypowsybl/sensitivity/impl/sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#
from __future__ import annotations

import warnings
from typing import List, Dict

from pypowsybl import _pypowsybl
Expand Down Expand Up @@ -71,6 +73,8 @@ def set_branch_flow_factor_matrix(self, branches_ids: List[str], variables_ids:
branches_ids: IDs of branches for which active power flow sensitivities should be computed
variables_ids: variables which may impact branch flows,to which we should compute sensitivities
"""
warnings.warn("set_branch_flow_factor_matrix is deprecated, use add_branch_flow_factor_matrix instead",
DeprecationWarning)
self.add_branch_flow_factor_matrix(branches_ids, variables_ids)

def add_branch_flow_factor_matrix(self, branches_ids: List[str], variables_ids: List[str],
Expand Down

0 comments on commit 75f3721

Please sign in to comment.