C++ code should conform to Google C++ Style Guide.
Deepray uses clang-format to check your C/C++ changes. Sometimes you have some manually formatted code that you don’t want clang-format to touch. You can disable formatting like this:
int formatted_code;
// clang-format off
void unformatted_code ;
// clang-format on
void formatted_code_again;
Install Clang-format 9 for Ubuntu:
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository -u 'http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
sudo apt install clang-format-9
format all with:
clang-format-9 -i --style=google ./deepray/**/*.cc ./deepray/**/*.h
Install Clang-format for MacOS:
brew update
brew install clang-format
format all with:
clang-format -i --style=google **/*.cc deepray/**/*.h
Deepray use Yapf to format our code. The continuous integration check will fail if you do not use it.
Install them with:
pip install yapf
Be sure to run it before you push your commits, otherwise the CI will fail!
yapf --style=./.yapf -ir ./**/*.py
Follow the guidance in the TensorFlow Style Guide - Conventions.
Please note that Deepray follows the conventions of the TensorFlow library, but formats our code using PEP8 guidelines.