Coding styleΒΆ

HyperSpy follows the Style Guide for Python Code - these are rules for code consistency that you can read all about in the Python Style Guide. You can use the black code formatter to automatically fix the style of your code. You can install and run black by:

pip install black
black /path/to/your/

In Linux and MacOS you can run black automatically after each commit by adding a post-commit file to .git/hook with the following content:

# From
FILES=$(git diff HEAD^ HEAD --name-only --diff-filter=ACM | grep -e '\.py$')
if [ -n "$FILES" ]; then
    for f in $FILES
        # black correction
        black -v $f
        git add $f
#git commit -m "Automatic style corrections courtesy of black"
commit --author="black <>" -m "Automatic style
corrections courtesy of black"