Conversation
…testing via an example of a manual test to illustrate the idea and the fallbacks of doing it manually. Then introduces Snaptol to automate the file management process, as well as introduce the capability of tolerances on comparisons involving floating point numbers. Introduce 3 exercises of increasing difficulty, along with solutions.
Thank you!Thank you for your pull request 😃 🤖 This automated message can help you check the rendered files in your submission for clarity. If you have any questions, please feel free to open an issue in {sandpaper}. If you have files that automatically render output (e.g. R Markdown), then you should check for the following:
Rendered Changes🔍 Inspect the changes: https://github.com/ResearchCodingClub/python-testing-for-research/compare/md-outputs..md-outputs-PR-11 The following changes were observed in the rendered markdown documents: What does this mean?If you have source files that require output and figures to be generated (e.g. R Markdown), then it is important to make sure the generated figures and output are reproducible. This output provides a way for you to inspect the output in a diff-friendly manner so that it's easy to see the changes that occur due to new software versions or randomisation. ⏱️ Updated at 2026-02-13 18:23:22 +0000 |
LiamPattinson
left a comment
There was a problem hiding this comment.
Thanks @avadean! Just leaving a few comments for now, as I'll be working on a bunch of my own material over the weekend which will inform the final review. I'm close to finishing a lesson on floating point numbers which might help simplify some of the content here.
| ```bash | ||
| pip install pytest-regtest | ||
| ``` | ||
| It is good practice to add these types of tests to all projects. They are particularly useful, |
There was a problem hiding this comment.
I'd maybe soften the argument here, and just stick with the concrete reasons they're a good idea
| It is good practice to add these types of tests to all projects. They are particularly useful, | |
| They are particularly useful, |
| not have an exact answer but can be approximated numerically within a given tolerance. This, along with the common use | ||
| of controlled randomised initial conditions, can lead to results that differ slightly between runs. | ||
|
|
||
| In the example below, we approximate the value of pi using a random sample of points in a square. The exact |
There was a problem hiding this comment.
I've been working on an earlier section that introduces testing floating point numbers with tolerances, and by chance I've used the exact same algorithm to demonstrate it. It might be worth rewriting this section to reuse the code from my section after I've raised my own PR.
|
|
||
| ```bash | ||
| pip install numpy pandas matplotlib pytest pytest-regtest pytest-mpl | ||
| pip install numpy pandas matplotlib pytest pytest-regtest pytest-mpl snaptol |
There was a problem hiding this comment.
Can we remove pytest-regtest and pytest-mpl here?
Overhaul of the regression testing module