-
-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Some integration tests are non-deterministic #2833
Comments
My suggestion would either be to fix the parameters / random seed / etc of the test in order to produce a consistent result; or embrace the stochasticity and retain / expand this approach in a separate set of robustness tests that could be run periodically (i.e. separate from pull requests). In the longer term this latter approach could be considered as part of infrastructure discussions (e.g. #2315). |
That's interesting! The solver shouldn't be random at all, it's an entirely deterministic model and solver.... Something getting written/loaded to disc during the test that is changing the outcome? |
I think there initial states for the algebraic equations are perturbed with some noise, it might come from there. |
See #2356 . IMO |
@rtimms Ah, that's really helpful to know! I suspected something similar, but wasn't sure if this was going to be due to Casadi or PyBaMM (a quick check reveals a handful of other locations in PyBaMM where random numbers are also used [including some test routines]). I've just run a quick set of tests again on Although this leads to further questions over the role of random factors in testing, and whether perturbations should be turned on or off by default, these feel like broader issues for discussion. For now, can I suggest that I hunt down any tests that call code with random elements and simply fix their random seeds? This should prevent tests from failing due to reasons that are unrelated to recent codebase changes. |
@jsbrittain thanks, sounds like a sensible approach! |
PyBaMM Version
23.2 [develop branch, commit 8232ac4]
Python Version
3.9.16
Describe the bug
At least one integration test (
test_compare_SPMe_silicon_graphite
) is non-deterministic, which allows the test (and subsequently the test integration suite) to fail for reasons that may be unrelated to recent code changes.After encountering the issue during a pull request, I used the bash script below to examine the outcome of
test_compare_SPMe_silicon_graphite
over 100 iterations. The output log shows that the test failed 3 times (note that rerunning the script again resulted in no failures, suggesting that the failure rate is low, likely around 1-2%; however, since integration test are currently run over 3 OSs and 2 python versions, and this may not be the only impacted test, this increases the chance of encountering the failure).Steps to Reproduce
Relevant log output
The text was updated successfully, but these errors were encountered: