Skip to content

Commit 18120db

Browse files
committed
fix doc of create backend [skip ci]
Signed-off-by: DONNOT Benjamin <[email protected]>
1 parent 7291e31 commit 18120db

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

docs/developer/createbackend.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,59 @@ There are 4 **__main__** types of method you need to implement if you want to us
195195
be the case for *eg* :func:`grid2op.Observation.BaseObservation.simulate` or
196196
for :class:`grid2op.simulator.Simulator`.
197197

198+
init function
199+
----------------
200+
201+
The `__init__` function of your backend class should accept key-word arguments
202+
`detailed_infos_for_cascading_failures` and `can_be_copied`.
203+
204+
It should also avoid regular arguments (some part of the code recreate backend instanced based on
205+
key-wrod arguments).
206+
207+
We recommend you do something like this :
208+
209+
.. code-block:: python
210+
211+
def __init__(self,
212+
detailed_infos_for_cascading_failures:bool=False,
213+
can_be_copied:bool=True,
214+
OTHER_KWARGS_1,
215+
OTHER_KWARGS_2,
216+
ETC):
217+
Backend.__init__(
218+
self,
219+
detailed_infos_for_cascading_failures=detailed_infos_for_cascading_failures,
220+
can_be_copied=can_be_copied,
221+
OTHER_KWARGS_1=OTHER_KWARGS_1,
222+
OTHER_KWARGS_2=OTHER_KWARGS_2,
223+
)
224+
225+
226+
For example the top first lines of the code of PandaPowerBackend looks like:
227+
228+
.. code-block:: python
229+
230+
def __init__(
231+
self,
232+
detailed_infos_for_cascading_failures : bool=False,
233+
lightsim2grid : bool=False, # use lightsim2grid as pandapower powerflow solver
234+
dist_slack : bool=False,
235+
max_iter : int=10,
236+
can_be_copied: bool=True,
237+
with_numba: bool=NUMBA_,
238+
):
239+
240+
# small irrelevant piece of code
241+
242+
Backend.__init__(
243+
self,
244+
detailed_infos_for_cascading_failures=detailed_infos_for_cascading_failures,
245+
can_be_copied=can_be_copied,
246+
lightsim2grid=lightsim2grid,
247+
dist_slack=dist_slack,
248+
max_iter=max_iter,
249+
with_numba=with_numba,
250+
)
198251
199252
.. _grid-description:
200253

docs/mdp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ The solver is then called and there are 2 alternatives (again):
654654
terminal state :math:`s_{\emptyset}` (ignore all the steps bellow)
655655
#. or a physical solution is found and the process carries out in the next steps
656656

657-
.. _mdp--emulation-step:
657+
.. _mdp-protection-emulation-step:
658658

659659
Step 5: Emulation of the "protections"
660660
++++++++++++++++++++++++++++++++++++++++++

0 commit comments

Comments
 (0)