- 
                Notifications
    
You must be signed in to change notification settings  - Fork 541
 
Coding conventions
        Peter Corke edited this page Feb 14, 2021 
        ·
        4 revisions
      
    PEP 8 rules
We aspire to the Zen of Python
see detailed doc string conventions here
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 mplimport matplotlib.pyplot as ppt- 
import mpl_toolkits.mplot3das mpl3d` 
 - Spatial Math Toolbox
import spatialmath as smfrom 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 
 - for toolbox code, to avoid circular imports always just import the required class, eg. 
 - all other imports
 
We use pytest
We use codecov to analyse and display unit test coverage, we aim for over 90% coverage.
We use LGTM to analyse and display code quality, we aim for an A rating.
We strive to be Pythonic rather than MATLABish.
- we prefer 
for x in Xrather thanfor i in range()and indexing. IfXis a NumPy array thenxiterates over matrix rows. If we do need an index as well as the object, then useenumerate(). - we test arguments for appropriateness and raise a 
ValueErrororTypeError - for argument checking we use 
spatialmath.base.argcheck- we test for a scalar argument using 
isscalar - we test for a vector argument using 
isvectorwhich accepts a Python list, tuple or NumPy array 
 - we test for a scalar argument using 
 
- Frequently asked questions (FAQ)
 - Documentation Style Guide
 - Typing Style Guide
 - Background
 - Key concepts
 - Introduction to robot and link classes
 - Working with Jupyter
 - Working from the command line
 - What about Simulink?
 - How to contribute
 - Common Issues
 - Contributors