stochasticHydroTools / libMobility

A collection of tools to compute hydrodynamic displacements.
MIT License
4 stars 0 forks source link

Better tests #3

Closed RaulPPelaez closed 6 months ago

RaulPPelaez commented 9 months ago

Writing automated unit tests would take this repo to the next level.

The current tests are more "does it run" tests.

We could use pytest for the python side and GTest for the C++ part. Although the python side is just a wrapper for the C++ library, so the python tests would probably suffice in most cases for correctness, while the C++ ones we could leave as "does it run".

I have never found a really good way to test for correctness in these kind of codes. Normally I test some limits (for instance, "does the doubly periodic code reproduces an open boundary when Lz>>Lx,Ly?"), but that can hide subtle bugs because you cannot have a lot of digits of precision. Ideas are welcome!

See for instance how I test the FCM in UAMMD: https://github.com/RaulPPelaez/UAMMD/blob/455a271dd270722e0fd4c8019fe9cafc7958bd57/test/BDHI/FCM/fcm_test.cu#L77

In addition to that, we should set up a Github CI to run these tests automatically on every new commit/PR. In practice this amounts to having a special script in the repo that will compile and run the tests on a GH-provided machine. See for instance here https://github.com/openmm/openmm-torch/blob/master/.github/workflows/CI.yml