Skip to content

Coding Tips

In this book, we use Python as our programming language. In the main chapters, we will focus on the theories and actual code and skip the basic concepts. To make sure we are on the same page, we shove all the tech stack related topics into this chapter for future reference. It is not necessary to read this chapter before reading the main chapters. However, we recommend the readers go through this chapter at some point to make sure they are not missing some basic engineering concepts.


This chapter is not aiming to be a comprehensive note on these technologies but a few key components that may be missing in many research-oriented tech stacks. We assume the readers have worked with the essential technologies in a Python-based deep learning project.

Good References for Coding in Research

Some skills only take a while to learn but people benefit from them for their whole life. Managing code falls exactly into this bucket, for programmers.

The Good Research Code Handbook is a very good and concise guide to building good coding habits. This should be a good first read.

The Alan Turing Institute also has a Research Software Engineering with Python course. This is a comprehensive generic course for boosting Python coding skills in research.

A Checklist of Tech Stack

We provide a concise list of tools for coding. Most of them are probably already integrated into most people's workflows. Hence we provide no descriptions but only the list itself.

In the following diagrams, we highlight the recommended tools using orange color. Clicking on them takes us to the corresponding website.

The first set of checklists is to help us set up a good coding environment.

flowchart TD
classDef highlight fill:#f96;

env["Setting up Coding Environment"]
git["fa:fa-star Git"]:::highlight
ide["Integrated Development Environment (IDE)"]
vscode["Visual Studio Code"]:::highlight
jupyter["Jupyter Notebooks"]
python["Python Environment"]
py_env["Python Environment Management"]
pyenv_venv["Pyenv + venv + pip"]
pyenv_poetry["Pyenv + poetry"]

click git "" "Git"
click precommit "" "pre-commit"
click vscode "" "Visual Studio Code"
click jupyter "" "Jupyter Lab"
click pycharm "" "PyCharm"
click conda "" "Anaconda"
click pyenv "" "pyenv"
click venv "" "venv"
click poetry "" "poetry"

env --- git
git --- precommit

env --- ide
ide --- vscode
ide --- jupyter
ide --- pycharm

env --- python
python --- py_env
py_env --- conda
py_env --- pyenv_venv
py_env --- pyenv_poetry

pyenv_venv --- pyenv
pyenv_venv --- venv

pyenv_poetry --- pyenv
pyenv_poetry --- poetry

The second set of checklists is to boost our code quality.

flowchart TD
classDef highlight fill:#f96;

python["Python Code Quality"]
test["Test Your Code"]

click pytest "" "pytest"
click black "" "black"
click isort ""
click mypy ""
click pylint ""
click flake8 ""
click pylama ""

python --- test
test --- pytest

python --- formatter
formatter --- black
formatter --- isort

python --- linter
linter --- mypy
linter --- pylint
linter --- flake8
linter ---pylama

Finally, we also mention the primary python packages used here.

flowchart TD
classDef highlight fill:#f96;

dataml["Data and Machine Learning"]
lightning["PyTorch Lightning"]:::highlight
much_more["and more ..."]

click pandas ""
click pytorch ""
click lightning ""

dataml --- pandas
dataml --- pytorch
dataml --- lightning
dataml --- much_more

Contributors: LM