Fail fast - coder sereinement : Tests dans Jupyter
written by
Graham Knapp
on 2021-06-14
Following the "fail fast" principal I have found it really useful when coding engineering and data science code in Jupyter to follow this pattern:
- Write the code in a Jupyter notebook - this is a great option for scientific and technical computing as it lets you combine code, visualisation and documentation all in the same place.
- Find independent sample calculations from text books or other commonly used tools - the key is that the examples should not be generated from your own code.
- Add sample calculations with assert statements in the same cell as the function definition to demonstrate that the function works.
This last point is the key to the method I suggest here - the tests are run every time you update your definition but if the test is slow it will only be run the first time you reopen the notebook, once you are happy with the function you can reuse it without re-running the tests
https://github.com/dancergraham/fail_fast
talks
python