Coding standards#

Coding style#

We follow:

  • the PEP8 coding guidelines. A good example can be found here

  • code formatting according to black, flake8, isort, numpydoc

Code formatting and linting#

We adhere to the following code formatting standards:

This is enforced through our CI/CD workflows via pre-commit

The full pre-commit configuration can be found in .pre-commit-config.yaml. Additional configurations can be found in pyproject.toml.

aeon specific code formatting conventions#

  • Check out our glossary.

  • Use underscores to separate words in non-class names: n_instances rather than ninstances.

  • exceptionally, capital letters X, Y, Z, are permissible as variable names or part of variable names such as X_train if referring to data sets, in accordance with the PEP8 convention that such variable names are permissible if in prior use in an area (here, this is the scikit-learn adjacenet ecosystem)

  • Avoid multiple statements on one line. Prefer a line return after a control flow statement (if/for).

  • Use absolute imports for references inside aeon.

  • Don’t use import * in the source code. It is considered harmful by the official Python recommendations. It makes the code harder to read as the origin of symbols is no longer explicitly referenced, but most important, it prevents using a static analysis tool like pyflakes to automatically find bugs.

Setting up local code quality checks#

There are two options to set up local code quality checks:

  • using pre-commit for automated code formatting

  • setting up black, flake8, isort and/or numpydoc manually in a local dev IDE

Using pre-commit#

To set up pre-commit, follow these steps in a python environment with the aeon dev dependencies installed.

Type the below in your python environment, and in the root of your local repository clone:

  1. If not already done, ensure aeon with dev dependencies is installed, this includes pre-commit:

pip install -e .[dev]
  1. Set up pre-commit:

pre-commit install

Once installed, pre-commit will automatically run all aeon code quality checks on the files you changed whenever you make a new commit.

If you want to exclude some line of code from being checked, you can add a #noqa (no quality assurance) comment at the end of that line.

Integrating with your local developer IDE#

Local developer IDEs will usually integrate with common code quality checks, but need setting them up in IDE specific ways.

For Visual Studio Code, black, flake8, isort and/or numpydoc will need to be activated individually in the preferences (e.g., search for black and check the box). The packages black etc will need to be installed in the python environment used by the IDE, this can be achieved by an install of aeon with dev dependencies.

Visual Studio Code preferences also allow setting of parameters such as max_line_length=88 for flake8.

In Visual Studio Code, we also recommend to add "editor.ruler": 88 to your local settings.json to display the max line length.