Skip to content

Commit

Permalink
Clean doc setup (#784)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
  • Loading branch information
geofjamg committed Aug 24, 2024
1 parent ba28c19 commit 6f652f9
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 60 deletions.
18 changes: 13 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 0 additions & 6 deletions docs/user_guide/dynamic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 0 additions & 14 deletions docs/user_guide/flowdecomposition.rst
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 0 additions & 4 deletions docs/user_guide/loadflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
7 changes: 0 additions & 7 deletions docs/user_guide/network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...
Expand Down
7 changes: 0 additions & 7 deletions docs/user_guide/per_unit.rst
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
11 changes: 1 addition & 10 deletions docs/user_guide/security.rst
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions docs/user_guide/voltage_initializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------

Expand Down
2 changes: 1 addition & 1 deletion pypowsybl/security/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6f652f9

Please sign in to comment.