-
Notifications
You must be signed in to change notification settings - Fork 34
Change-point tests #1295
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
Draft
DavAug
wants to merge
85
commits into
main
Choose a base branch
from
issue-1294-functional-testing-module
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Change-point tests #1295
Changes from 16 commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
23a69ac
#1294 functional test HaarioBardenet
DavAug b852dd3
@1294 add copyright notice
DavAug 4e5bef1
#1294 exclude functional tests from coverage rep
DavAug 6e36010
#1294 add copyright notice
DavAug 5986250
#1294 flake8
DavAug 3bc6fee
Make test importable
fcooper8472 d297099
Return a string of the class name
fcooper8472 5e14e66
Add skeleton for functional testing workflow
fcooper8472 a1be118
Merge branch 'master' into issue-1294-functional-testing-module
fcooper8472 29d52f7
I think this is the correct syntax for not running on draft pr...
fcooper8472 d176527
Try committing changes to functional testing
fcooper8472 6f14364
Fix syntax
fcooper8472 36aa00b
Remove diff
fcooper8472 128f66e
Bump
fcooper8472 2c360e7
Bump
fcooper8472 d28387d
Bump
fcooper8472 fdbf30d
#1294 update structure
fcooper8472 1225905
#1294 allow setting of hyper parameters
fcooper8472 09af996
Added banana problem
ben18785 f42b5cf
Added gaussian and banana tests for differential evolution
ben18785 774d460
Moved controller initialisation methods to parent class
ben18785 6d8c553
Added dream
ben18785 63a674d
Added Haario to functional tests
ben18785 d3d8f41
added functional tests for emcee hammer
ben18785 d076b1a
Added sample sizes as optional parameter for tests
ben18785 e9fd8ab
Added high dim Gaussian problem
ben18785 25be93f
Merge branch 'master' into issue-1294-functional-testing-module
ben18785 4f4b9ea
Added nuts problems
ben18785 73c8a8c
Added correlated Gaussian and started to add DRAM but found a bug
ben18785 7bdef09
Added banana test for dram
ben18785 8f528d2
Simplified starting points for problems.
ben18785 7f57caf
Added correlated Gaussian test for haario-bardenet
ben18785 d9ef3c6
Corrected func test name for haario bardenet
ben18785 8429f10
Update haario_bardenet_acmc.py
ben18785 88a4803
Added annulus problem for Haario-bardenet
ben18785 d1b0c9a
expose some more functional tests
fcooper8472 ac0bf23
bump
fcooper8472 e580c62
Merge branch 'master' into issue-1294-functional-testing-module
ben18785 7a7d9ab
Added problems for emcee hammer
ben18785 81436e0
Added cone problem
ben18785 8ae5c5f
Added monomial gamma problems
ben18785 9e48d20
Delete empty ending line
chonlei 5eccd57
Rename to haario_acmc.py and add correlated Gaussian problem
chonlei 20adc16
add correlated gaussian and annulus to differential evolution functests
rccreswell de66391
add correlated gaussian and annulus to dream functests
rccreswell d55f7d2
Add problems for Metropolis functests
chonlei 494574f
add relativistic problems
rccreswell aa55906
Functional testing for slice stepout
FarmHJ 3b0f961
update relativistic functional test hyperparameters
rccreswell 6212de2
Merge branch 'issue-1294-functional-testing-module' of https://github…
rccreswell 033f29e
Merge branch 'master' into issue-1294-functional-testing-module
MichaelClerx 24603ab
Updated tests for Population MCMC.
MichaelClerx f1f3fda
Made all functional test classes modules have names that match the me…
MichaelClerx 30d4e44
Removed 'test_method_on' prefix from all functional tests, so they ca…
MichaelClerx e029413
Updated the way functionaltest modules and problem classes are imported.
MichaelClerx c83bfc3
Removed 'from __future__' imports.
MichaelClerx 3edbeb1
Added docstrings to functional tests.
MichaelClerx 3b0e026
Updated way iterations and warmup is set in functional tests.
MichaelClerx c9cb226
Added functional test discovery mechanism.
MichaelClerx 32033d5
Add MALA methods
fcooper8472 c3d98dc
Merge pull request #1388 from pints-team/mala
ben18785 325a674
Merge branch 'issue-1294-functional-testing-module' into func-test-or…
MichaelClerx 6c8f607
Updated new MALA tests.
MichaelClerx 1e434c5
Updated new MALA tests.
MichaelClerx 14c0263
Made ft warmup a user-set parameter.
MichaelClerx 2ed963f
Slightly simplified ft code.
MichaelClerx e89e2ba
Merge pull request #1386 from pints-team/func-test-organising
MichaelClerx 4d757a3
Renamed function to change point tests. Closes #1391.
MichaelClerx 6247830
Merge branch 'master' into issue-1294-functional-testing-module
MichaelClerx 0fcd400
Changed 'ft' to 'cpt'.
MichaelClerx 9aa1592
Added flag to ignore unused import in cptests.__init__
MichaelClerx a602921
Merge pull request #1392 from pints-team/func-test-rename
MichaelClerx 665f21c
Fixed merge issue in workflows.
MichaelClerx b54bf9a
Updated workflow
MichaelClerx 12e7e67
Disabled `banana` & added `annulus` in `hamiltonian_mcmc`.
YongchaoHuang e2e3969
Merge pull request #1510 from pints-team/main
MichaelClerx 8275e17
Style fix and hmc cptest fix
MichaelClerx ad9e422
Remove banana and multimodal gaussian problem for slice stepout mcmc
FarmHJ 66e58f3
Add problems for functional test of slice doubling
FarmHJ 3b2864d
Added optimiser problems and tests on CMAES
MichaelClerx 6bb0255
Added cmaes-bare cptests
MichaelClerx 6970872
Added xNES tests (requires fix from #1517).
MichaelClerx 0294abc
Added SNES tests
MichaelClerx f7e6b6b
Add test for HMC
FarmHJ 3e169ba
Merge branch 'issue-1294-functional-testing-module' of https://github…
FarmHJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| source = pints | ||
| omit = | ||
| pints/tests/* | ||
| pints/functionaltests/* | ||
|
|
||
| [report] | ||
| exclude_lines = | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: Functional testing | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - issue-1294-functional-testing-module | ||
|
|
||
| jobs: | ||
|
|
||
| run-functional-testing: | ||
| name: Functional testing | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out PINTS repository | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| path: 'pints' | ||
|
|
||
| - name: Check out functional-testing-2 repository | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| repository: 'pints-team/functional-testing-2' | ||
| ref: 'new-infra' | ||
| path: 'functional-testing-2' | ||
| token: ${{ secrets.FUNCTIONAL_TESTING_TOKEN }} | ||
|
|
||
| - name: Set up Python 3.8 | ||
| uses: actions/setup-python@v1 | ||
| with: | ||
| python-version: 3.8 | ||
| architecture: x64 | ||
|
|
||
| - name: install pints | ||
| run: | | ||
| python --version | ||
| python -m pip install --upgrade pip setuptools wheel | ||
| python -m pip install . | ||
| working-directory: 'pints' | ||
|
|
||
| - name: install functional-testing-2 | ||
| run: | | ||
| python -m pip install . | ||
| working-directory: 'functional-testing-2' | ||
|
|
||
| - name: run functional testing | ||
| run: | | ||
| python run_all_the_things.py | ||
| working-directory: 'functional-testing-2' | ||
|
|
||
| - name: commit changes | ||
| run: | | ||
| git config user.name "github-workflow" | ||
| git config user.email "github-workflow" | ||
| git add --all | ||
| git commit -m "Run of functional testing" || echo "No changes to commit" | ||
| git push | ||
| working-directory: 'functional-testing-2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # | ||
| # This file is part of PINTS (https://github.com/pints-team/pints/) which is | ||
| # released under the BSD 3-clause license. See accompanying LICENSE.md for | ||
| # copyright notice and full license details. | ||
| # | ||
|
|
||
| from .functest_haario_bardenet_acmc import TestHaarioBardenetACMCOn2dimGaussianDistribution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| #!/usr/bin/env python3 | ||
| # | ||
| # This file is part of PINTS (https://github.com/pints-team/pints/) which is | ||
| # released under the BSD 3-clause license. See accompanying LICENSE.md for | ||
| # copyright notice and full license details. | ||
| # | ||
|
|
||
| from __future__ import division | ||
|
|
||
| import numpy as np | ||
|
|
||
| import pints | ||
| import pints.toy | ||
|
|
||
|
|
||
| class TestHaarioBardenetACMCOn2dimGaussianDistribution(object): | ||
| """ | ||
| Tests the pints.HaarioBardenetACMC on a standard 2 dimensional Gaussian | ||
| distribution. | ||
| """ | ||
| def __init__(self): | ||
| # Define calibrated test parameters | ||
| n_chains = 3 | ||
| n_iterations = 4000 | ||
| warmup = 1000 | ||
| method = pints.HaarioBardenetACMC | ||
|
|
||
| # Define pdf | ||
| self.pdf = pints.toy.GaussianLogPDF(mean=[0, 0], sigma=[1, 1]) | ||
|
|
||
| # Get initial parameters | ||
| log_prior = pints.ComposedLogPrior( | ||
| pints.GaussianLogPrior(mean=0, sd=100), | ||
| pints.GaussianLogPrior(mean=0, sd=100)) | ||
| initial_parameters = log_prior.sample(n=n_chains) | ||
|
|
||
| # Set up sampler | ||
| sampler = pints.MCMCController( | ||
| self.pdf, n_chains, initial_parameters, method=method) | ||
| sampler.set_max_iterations(n_iterations) | ||
| sampler.set_log_to_screen(False) | ||
|
|
||
| # Infer posterior and throw away warm-up | ||
| chains = sampler.run() | ||
| self.chains = chains[:, warmup:] | ||
|
|
||
| def estimate_kld(self): | ||
| """ | ||
| Estimates and returns the Kullback-Leibler divergence between the | ||
| approximate posterior and the true posterior assuming that the | ||
| approximated posterior has Gaussian shape. | ||
| """ | ||
| # Pool samples from chains | ||
| chains_x = self.chains[:, :, 0].flatten() | ||
| chains_y = self.chains[:, :, 1].flatten() | ||
| chains = np.vstack([chains_x, chains_y]).T | ||
|
|
||
| return self.pdf.kl_divergence(chains) | ||
|
|
||
| def estimate_mean_ess(self): | ||
| """ | ||
| Estimates the effective sample size (ESS) for each chain and each | ||
| parameter and returns the mean ESS for across all chains and | ||
| parameters. | ||
| """ | ||
| # Estiomate mean ESS for each chain | ||
| n_chains, _, n_parameters = self.chains.shape | ||
| ess = np.empty(shape=(n_chains, n_parameters)) | ||
| for chain_id, chain in enumerate(self.chains): | ||
| ess[chain_id] = pints.effective_sample_size(chain) | ||
|
|
||
| return np.mean(ess) | ||
|
|
||
| def get_results(self): | ||
| """ | ||
| Runs the functional tests and returns the results. | ||
| """ | ||
| results = {} | ||
|
|
||
| # Estimate | ||
| results['kld'] = self.estimate_kld() | ||
| results['mean-ess'] = self.estimate_mean_ess() | ||
|
|
||
| return results | ||
|
|
||
| @staticmethod | ||
| def get_name(): | ||
| """ | ||
| Returns the name of this class. | ||
| """ | ||
| return 'TestHaarioBardenetACMCOn2dimGaussianDistribution' | ||
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.
Uh oh!
There was an error while loading. Please reload this page.