diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1531bb88..e4a71d4fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,9 +11,10 @@ possible. and after the change. Examples of benchmarks can be found in `benchmarks/python/`. 4. If you've changed APIs, update the documentation. 5. Every PR should have passing tests and at least one review. -6. For code formatting install `pre-commit` using something like `pip install pre-commit` and run `pre-commit install`. +6. For code formatting install `pre-commit`, `black` and `clang-format` using something like `pip install pre-commit black clang-format` and run `pre-commit install`. This should install hooks for running `black` and `clang-format` to ensure consistent style for C++ and python code. + For convenience, you can set up the repository-specific Python virtualenv inside the `venv` directory at the root of the repository - it is ignored by git. You can also run the formatters manually as follows: diff --git a/examples/cpp/tutorial.cpp b/examples/cpp/tutorial.cpp index 091dfab2d..c2b1a62db 100644 --- a/examples/cpp/tutorial.cpp +++ b/examples/cpp/tutorial.cpp @@ -89,8 +89,10 @@ void automatic_differentiation() { // dfdx is 2 * x // Get the second derivative by composing grad with grad - auto df2dx2 = grad(grad(fn))(x); - // df2dx2 is 2 + auto d2fdx2 = grad(grad(fn))(x); + // d2fdx2 is 2 + std::cout << d2fdx2 << std::endl; + assert(d2fdx2.item() - 2.0 <= std::numeric_limits::epsilon()); } int main() {