Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Coding conventions

Richard Murray edited this pageNov 27, 2024 ·7 revisions

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 naming conventions

  • 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.

Docstring conventions

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:

  1. Short summary: one line summary (shows up in tables).
  2. Extended Summary: A few sentences giving an extended description.
  3. Parameters: Description of the function arguments, keywords and their respective types. Format should be
    parameter : type    Short description
    The type should either be a Python type, a NumPy class, or a python-control class, ideally with a:class: prefix to generate a link to the appropriate class.
  4. Returns: Explanation of the returned values and their types.
  5. Other Parameters: An optional section used to describe infrequently used parameters.
  6. See Also: An optional section used to refer to related code.
  7. 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.
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp