Added full inversion test with all required data #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a test that runs
fixedbasisMCMC
for one iteration with 4 basis functions, over two days of data. It runs in about 20 seconds, so it should be useful for checking that minor changes to the code don't break existing functionality.This test doesn't cover the
run_hbmcmc
script. The changes tohbmcmc.py
are mostly due to black; there are a few changes to make it easier to choose where the quadtree basis is saved.I added a test with more iterations, which is marked "slow". I set up pytest.ini to not run "slow" tests by default. The slow test uses a week of data, 50 basis functions, and 5000 iterations; it runs in about 7-8 minutes on my macbook.
In the future, I may add more "slow" tests that are marked "blue_pebble", which will only run on blue pebble, for tuning purposes. (Alternatively, this could be done with a separate script.)
For set-up,
conftest.py
creates an object in a temporary directory using some data files distributed withopenghg_inversions
. If this object store already exists and has data in it, then no data is standardised, which should speed up subsequent tests. (This is also atest_conftest.py
file that checks if the right data is available.) Some data needed to run the inversion test isn't stored in the object store; this data is added to "bc_basis_functions" and "countries" by conftest when the tests are first run (if they don't exist, conftest creates these directories.)To keep the
openghg_inversions
repo clean while running tests, I changed howquadtreebasis
works: if "outputdir" is passed, then the basis is saved there, rather than in a temporary directory (which with the current code, would be created where the tests are run from). I also added some safe guards to the part ofhbmcmc.py
that deletes the temporary basis file. Saving the quadtree to the output folder is controlled by a flag infixedbasisMCMC
, so it doesn't change the behaviour of the code unless you ask it to.Closes issue #8.