diff --git a/docs/conf.py b/docs/conf.py index ff0ba97257..55b83f06ac 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -89,11 +89,19 @@ html_css_files = ['styles/styles.css'] doctest_global_setup = ''' -try: - import pypowsybl as pp - pp.set_config_read(False) -except ImportError: - pp = None +import pypowsybl as pp +pp.set_config_read(False) + +import pathlib + +import pandas as pd +pd.options.display.max_columns = None +pd.options.display.expand_frame_repr = False + +import os +cwd = os.getcwd() +PROJECT_DIR = pathlib.Path(cwd).parent +DATA_DIR = PROJECT_DIR.joinpath('data') ''' on_rtd = os.environ.get('READTHEDOCS') == 'True' diff --git a/docs/user_guide/dynamic.rst b/docs/user_guide/dynamic.rst index 416fea7557..f445276e40 100644 --- a/docs/user_guide/dynamic.rst +++ b/docs/user_guide/dynamic.rst @@ -3,12 +3,6 @@ Running a dynamic simulation with dynawaltz .. currentmodule:: pypowsybl.dynamic -.. testsetup:: * - - import pypowsybl as pp - import pypowsybl.dynamic as dyn - import pypowsybl.network as pn - You can use the module :mod:`pypowsybl.dynamic` in order to run time domain simulation on networks. Start by importing the module: diff --git a/docs/user_guide/flowdecomposition.rst b/docs/user_guide/flowdecomposition.rst index fedb7cf380..c153903600 100644 --- a/docs/user_guide/flowdecomposition.rst +++ b/docs/user_guide/flowdecomposition.rst @@ -1,20 +1,6 @@ Running a flow decomposition ============================ -.. testsetup:: * - - import pathlib - import pandas as pd - - import pypowsybl as pp - - pd.options.display.max_columns = None - pd.options.display.expand_frame_repr = False - import os - cwd = os.getcwd() - PROJECT_DIR = pathlib.Path(cwd).parent - DATA_DIR = PROJECT_DIR.joinpath('data') - You can use the module :mod:`pypowsybl.flowdecomposition` in order to run flow decomposition on networks. Please check out the examples below. diff --git a/docs/user_guide/loadflow.rst b/docs/user_guide/loadflow.rst index 0f9297316f..abe722b8d9 100644 --- a/docs/user_guide/loadflow.rst +++ b/docs/user_guide/loadflow.rst @@ -5,12 +5,8 @@ Running a load flow .. testsetup:: * - import pypowsybl as pp import pypowsybl.loadflow as lf import pypowsybl.network as pn - import pandas as pd - pd.options.display.max_columns = None - pd.options.display.expand_frame_repr = False You can use the module :mod:`pypowsybl.loadflow` in order to run load flows on networks. diff --git a/docs/user_guide/network.rst b/docs/user_guide/network.rst index d14ab7a1eb..ab709cbddb 100644 --- a/docs/user_guide/network.rst +++ b/docs/user_guide/network.rst @@ -3,13 +3,6 @@ The network model .. currentmodule:: pypowsybl.network -.. testsetup:: * - - import pandas as pd - pd.set_option('display.max_columns', None) - pd.set_option('display.expand_frame_repr', False) - - The :class:`Network` object is the main data structure of pypowsybl. It contains all the data of a power network: substations, generators, lines, transformers, ... diff --git a/docs/user_guide/per_unit.rst b/docs/user_guide/per_unit.rst index 762d353432..b9a7d6e063 100644 --- a/docs/user_guide/per_unit.rst +++ b/docs/user_guide/per_unit.rst @@ -1,13 +1,6 @@ Per Unit data ------------- -.. testsetup:: * - - import pypowsybl as pp - import pandas as pd - pd.options.display.max_columns = None - pd.options.display.expand_frame_repr = False - PyPowSyBl provides methods to per unit the scientific data. They are part of the network api. To per-unit the data, the attribute per_unit of the network has to be set. diff --git a/docs/user_guide/security.rst b/docs/user_guide/security.rst index b2af80c099..95094519bb 100644 --- a/docs/user_guide/security.rst +++ b/docs/user_guide/security.rst @@ -1,14 +1,6 @@ Running a security analysis =========================== -.. testsetup:: * - - import pypowsybl as pp - import pandas as pd - pd.options.display.max_columns = None - pd.options.display.expand_frame_repr = False - from pypowsybl._pypowsybl import ConditionType - You can use the module :mod:`pypowsybl.security` in order to perform a security analysis on a network. Please check out the examples below. @@ -55,7 +47,6 @@ Information can be obtained on buses, branches and three windings transformers. .. testsetup:: security.monitored_elements - import pandas as pd pd.options.display.float_format = '{:,.2f}'.format .. doctest:: security.monitored_elements @@ -131,7 +122,7 @@ The following operator strategy define the application of the switch action 'Swi >>> sa = pp.security.create_analysis() >>> sa.add_single_element_contingency(element_id='S4VL1_BBS_LD6_DISCONNECTOR', contingency_id='Breaker contingency') >>> sa.add_switch_action(action_id='SwitchAction', switch_id='S4VL1_BBS_LD6_DISCONNECTOR', open=False) - >>> sa.add_operator_strategy(operator_strategy_id='OperatorStrategy1', contingency_id='Breaker contingency', action_ids=['SwitchAction'], condition_type=ConditionType.TRUE_CONDITION) + >>> sa.add_operator_strategy(operator_strategy_id='OperatorStrategy1', contingency_id='Breaker contingency', action_ids=['SwitchAction'], condition_type=pp.security.ConditionType.TRUE_CONDITION) >>> sa.add_monitored_elements(branch_ids=['LINE_S3S4']) >>> sa_result = sa.run_ac(n) >>> df = sa_result.branch_results diff --git a/docs/user_guide/voltage_initializer.rst b/docs/user_guide/voltage_initializer.rst index 6dc82aeff9..be1ae654b4 100644 --- a/docs/user_guide/voltage_initializer.rst +++ b/docs/user_guide/voltage_initializer.rst @@ -3,12 +3,6 @@ Run the voltage initializer .. currentmodule:: pypowsybl.voltage_initializer -.. testsetup:: * - - import pypowsybl as pp - import pypowsybl.voltage_initializer as v_init - - Prerequisites ------------- diff --git a/pypowsybl/security/__init__.py b/pypowsybl/security/__init__.py index 3700422f2f..31c0bf9605 100644 --- a/pypowsybl/security/__init__.py +++ b/pypowsybl/security/__init__.py @@ -8,7 +8,7 @@ from .impl.increased_violations_parameters import IncreasedViolationsParameters from .impl.parameters import Parameters from .impl.security_analysis_result import SecurityAnalysisResult -from .impl.security import SecurityAnalysis, ComputationStatus, ContingencyContextType +from .impl.security import SecurityAnalysis, ComputationStatus, ContingencyContextType, ConditionType from .impl.util import ( create_analysis, set_default_provider,