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

Peter Corke edited this pageFeb 14, 2021 ·4 revisions

Style

PEP 8 rules

We aspire to theZen of Python

docstrings

seedetailed doc string conventions here

Package imports

At the top of each file we import packages in the following order

  • Standard Python packages
  • NumPy:import numpy as np
  • SciPy:import script as sp
  • Matplotlib
    • import matplotlib as mpl
    • import matplotlib.pyplot as ppt
    • import mpl_toolkits.mplot3d as mpl3d`
  • Spatial Math Toolbox
    • import spatialmath as sm
    • from spatialmath import base
  • Robotics Toolbox
    • for toolbox code, to avoid circular imports always just import the required class, eg.from roboticstoolbox.module import class
    • for application code,import roboticstoolbox as rtb
  • all other imports

Unit testing

We usepytest

Code quality

We usecodecov to analyse and display unit test coverage, we aim for over 90% coverage.

We useLGTM to analyse and display code quality, we aim for an A rating.

Coding patterns

We strive to be Pythonic rather than MATLABish.

  • we preferfor x in X rather thanfor i in range() and indexing. IfX is a NumPy array thenx iterates over matrix rows. If we do need an index as well as the object, then useenumerate().
  • we test arguments for appropriateness and raise aValueError orTypeError
  • for argument checking we usespatialmath.base.argcheck
    • we test for a scalar argument usingisscalar
    • we test for a vector argument usingisvector which accepts a Python list, tuple or NumPy array

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp