Skip to content

Coding Guidelines

Hrishikesh Dahiya edited this page Jan 23, 2018 · 1 revision

Coding Conventions

Follow the standard Style Guide for Python Code when writing code for MLCAT, 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.


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

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

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


You can’t perform that action at this time.