Skip to content

Coding Guidelines

Achyudh Ram edited this page Dec 31, 2017 · 5 revisions

Coding Conventions

Follow the standard Style Guide for Python Code when writing code for SCAT, as explained by PEP8

The following case convention is used in this project: module_name, package_name, ClassName, method_name, ExceptionName, function_name, GLOBAL_CONSTANT_NAME, global_var_name, instance_var_name, function_parameter_name, local_var_name, _private_var_name.

Especially,

  • Use 4 spaces for indentation levels.
  • Use all lowercase function names with words separated by underscores. For example, you are encouraged to write Python functions using the naming convention
def set_some_value()

instead of the CamelCase convention.

  • Use CamelCase for class names and major functions that create objects, e.g.
class PolynomialRing(object)

Note, however, that some functions do have uppercase letters where it makes sense. For example, for matrices they are LUdecomposition or T (transposition) methods.

Documentation Conventions

We use the following Google Style Python format for doctrings which is important for sphinx doc build:

def function_with_types_in_docstring(param1, param2):

    """Example function with types documented in the docstring.

    PEP 484_ type annotations are supported. If attribute, parameter, and
    return types are annotated according to PEP 484_, they do not need to be
    included in the docstring:

    Args:
        param1 (int): The first parameter.
        param2 (str): The second parameter.

    Returns:
        bool: The return value. True for success, False otherwise.
    """

References

http://docs.python-guide.org/en/latest/writing/style/

https://github.com/sympy/sympy/wiki/Development-workflow

https://github.com/hblanks/zen-of-python-by-example

https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt

https://docs.scipy.org/doc/scipy/reference/dev/index.html

https://matplotlib.org/devel/contributing.html

http://scikit-learn.org/stable/developers/index.html

Clone this wiki locally