- Notifications
You must be signed in to change notification settings - Fork441
Coding conventions
This page contains guidelines for coding conventions in python-control.
- We currently usePEP8 naming conventions as a baseline.
- We usenumpydoc for docstrings, with the users manual generated bysphinx
You should also take a look at thetesting conventions page.
Function names are lower case, with underscores between words.
Functions that carry out an action on an object and return a new object (or set of values) are written in verb form. Examples:
find_operating_point
,solve_ocp
.Functions that generate plots should end in
_plot
. Examples:bode_plot
,nyquist_plot
.For commands that map to MATLAB commands, it is not necessary to replicate the MATLAB command name if it violates the guidelines above. Instead, use the standard naming conventions and then create a second function object with the shortened name (eg,
bode = bode_plot
). You can also create an object in thematlab
module that users the same name and signature as the MATLAB command.
We usenumpydoc for docstrings, with the users manual generated bysphinx. In order for thereadthedocs to render properly, thenumpydoc conventions must be followed. Here's a short summary of the key conventions for standard functions:
- Short summary: one line summary (shows up in tables).
- Extended Summary: A few sentences giving an extended description.
- Parameters: Description of the function arguments, keywords and their respective types. Format should beThe type should either be a Python type, a NumPy class, or a python-control class, ideally with a
parameter : type Short description
:class:
prefix to generate a link to the appropriate class. - Returns: Explanation of the returned values and their types.
- Other Parameters: An optional section used to describe infrequently used parameters.
- See Also: An optional section used to refer to related code.
- Notes: An optional section that provides additional information about the code, possibly including a discussion of the algorithm. This section may include mathematical equations, written inLaTeX format.