Skip to content
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

Renamed function to change point tests. #1392

Merged
merged 3 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#
# "Functional test" module for PINTS.
# Change point tests for PINTS.
#
# 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.
#

# Import all problem classes straight into this module, so that they can be
# addressed as e.g. pints.functionaltests.RunMcmcMethodOnAnnulus.
# addressed as e.g. pints.cptests.RunMcmcMethodOnAnnulus.
from ._problems import ( # noqa
RunMcmcMethodOnAnnulus,
RunMcmcMethodOnBanana,
Expand All @@ -20,7 +20,7 @@

# Import all test modules (not methods!) directly into this method, so that
# they can be addressed as e.g.
# pints.functionaltests.dram_acmc.two_dim_gaussian().
# pints.cptests.dram_acmc.two_dim_gaussian().
from . import ( # noqa
differential_evolution_mcmc,
dram_acmc,
Expand All @@ -40,4 +40,4 @@


# Test discovery methods
from ._discovery import tests
from ._discovery import tests # noqa
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
#
# Functional test discovery methods for PINTS.
# Change point test discovery methods for PINTS.
#
# 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.
#
import inspect

import pints.functionaltests as ft
import pints.cptests as cpt


def tests(method=None):
"""
Returns a list of all functional tests, each represented as a tuple
Returns a list of all change point tests, each represented as a tuple
``(method, test)`` where ``method`` is the PINTS class being tested and
``test`` is a callable that returns the test results.

If the optional argument ``method`` is given, only tests for this method
are returned.
"""
# Get all modules imported into this module
modules = [getattr(ft, x) for x in dir(ft) if not x.startswith('_')]
modules = [getattr(cpt, x) for x in dir(cpt) if not x.startswith('_')]
modules = [x for x in modules if inspect.ismodule(x)]

# Look for (explicitly defined) tests
tests = []
for module in modules:
try:
m_method = module._method
m_tests = module._functional_tests
m_tests = module._change_point_tests
except AttributeError:
continue

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Shared problems used in functional testing.
# Shared problems used in change point testing.
#
# 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
#
# Functional tests for DifferentialEvolutionMCMC
# Change point tests for DifferentialEvolutionMCMC
#
# 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.
#
import pints
import pints.functionaltests as ft
import pints.cptests as cpt


def two_dim_gaussian(n_iterations=10000, n_warmup=1000):
Expand All @@ -17,9 +17,9 @@ def two_dim_gaussian(n_iterations=10000, n_warmup=1000):
``[0, 0]`` and returns a dictionary with entries ``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnTwoDimGaussian`.
:class:`pints.cptests.RunMcmcMethodOnTwoDimGaussian`.
"""
problem = ft.RunMcmcMethodOnTwoDimGaussian(
problem = cpt.RunMcmcMethodOnTwoDimGaussian(
_method, 10, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -34,9 +34,9 @@ def banana(n_iterations=5000, n_warmup=1000):
``[0, 0]`` and returns a dictionary with entries ``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnBanana`.
:class:`pints.cptests.RunMcmcMethodOnBanana`.
"""
problem = ft.RunMcmcMethodOnBanana(
problem = cpt.RunMcmcMethodOnBanana(
_method, 20, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -52,9 +52,9 @@ def correlated_gaussian(n_iterations=10000, n_warmup=1000):
``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnCorrelatedGaussian`.
:class:`pints.cptests.RunMcmcMethodOnCorrelatedGaussian`.
"""
problem = ft.RunMcmcMethodOnCorrelatedGaussian(
problem = cpt.RunMcmcMethodOnCorrelatedGaussian(
_method, 20, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -69,9 +69,9 @@ def annulus(n_iterations=10000, n_warmup=1000):
dictionary with entries ``distance`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnAnnulus`.
:class:`pints.cptests.RunMcmcMethodOnAnnulus`.
"""
problem = ft.RunMcmcMethodOnAnnulus(
problem = cpt.RunMcmcMethodOnAnnulus(
_method, 10, n_iterations, n_warmup)
return {
'distance': problem.estimate_distance(),
Expand All @@ -80,7 +80,7 @@ def annulus(n_iterations=10000, n_warmup=1000):


_method = pints.DifferentialEvolutionMCMC
_functional_tests = [
_change_point_tests = [
annulus,
banana,
correlated_gaussian,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
#
# Functional tests for DramACMC
# Change point tests for DramACMC
#
# 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.
#
import pints
import pints.functionaltests as ft
import pints.cptests as cpt


def two_dim_gaussian(n_iterations=8000, n_warmup=2000):
Expand All @@ -17,9 +17,9 @@ def two_dim_gaussian(n_iterations=8000, n_warmup=2000):
``[0, 0]`` and returns a dictionary with entries ``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnTwoDimGaussian`.
:class:`pints.cptests.RunMcmcMethodOnTwoDimGaussian`.
"""
problem = ft.RunMcmcMethodOnTwoDimGaussian(
problem = cpt.RunMcmcMethodOnTwoDimGaussian(
_method, 4, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -34,9 +34,9 @@ def banana(n_iterations=4000, n_warmup=1000):
``[0, 0]`` and returns a dictionary with entries ``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnBanana`.
:class:`pints.cptests.RunMcmcMethodOnBanana`.
"""
problem = ft.RunMcmcMethodOnBanana(
problem = cpt.RunMcmcMethodOnBanana(
_method, 4, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -52,9 +52,9 @@ def correlated_gaussian(n_iterations=8000, n_warmup=4000):
``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnCorrelatedGaussian`.
:class:`pints.cptests.RunMcmcMethodOnCorrelatedGaussian`.
"""
problem = ft.RunMcmcMethodOnCorrelatedGaussian(
problem = cpt.RunMcmcMethodOnCorrelatedGaussian(
_method, 4, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -63,7 +63,7 @@ def correlated_gaussian(n_iterations=8000, n_warmup=4000):


_method = pints.DramACMC
_functional_tests = [
_change_point_tests = [
banana,
correlated_gaussian,
two_dim_gaussian,
Expand Down
22 changes: 11 additions & 11 deletions pints/functionaltests/dream_mcmc.py → pints/cptests/dream_mcmc.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
#
# Functional tests for DreamMCMC
# Change point tests for DreamMCMC
#
# 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.
#
import pints
import pints.functionaltests as ft
import pints.cptests as cpt


def two_dim_gaussian(n_iterations=10000, n_warmup=1000):
Expand All @@ -17,9 +17,9 @@ def two_dim_gaussian(n_iterations=10000, n_warmup=1000):
``[0, 0]`` and returns a dictionary with entries ``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnTwoDimGaussian`.
:class:`pints.cptests.RunMcmcMethodOnTwoDimGaussian`.
"""
problem = ft.RunMcmcMethodOnTwoDimGaussian(
problem = cpt.RunMcmcMethodOnTwoDimGaussian(
_method, 10, n_iterations, n_warmup)

return {
Expand All @@ -35,9 +35,9 @@ def banana(n_iterations=5000, n_warmup=1000):
``[0, 0]`` and returns a dictionary with entries ``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnBanana`.
:class:`pints.cptests.RunMcmcMethodOnBanana`.
"""
problem = ft.RunMcmcMethodOnBanana(
problem = cpt.RunMcmcMethodOnBanana(
_method, 20, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -53,9 +53,9 @@ def correlated_gaussian(n_iterations=10000, n_warmup=1000):
``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnCorrelatedGaussian`.
:class:`pints.cptests.RunMcmcMethodOnCorrelatedGaussian`.
"""
problem = ft.RunMcmcMethodOnCorrelatedGaussian(
problem = cpt.RunMcmcMethodOnCorrelatedGaussian(
_method, 20, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -70,9 +70,9 @@ def annulus(n_iterations=10000, n_warmup=1000):
dictionary with entries ``distance`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnAnnulus`.
:class:`pints.cptests.RunMcmcMethodOnAnnulus`.
"""
problem = ft.RunMcmcMethodOnAnnulus(
problem = cpt.RunMcmcMethodOnAnnulus(
_method, 10, n_iterations, n_warmup)
return {
'distance': problem.estimate_distance(),
Expand All @@ -81,7 +81,7 @@ def annulus(n_iterations=10000, n_warmup=1000):


_method = pints.DreamMCMC
_functional_tests = [
_change_point_tests = [
annulus,
banana,
correlated_gaussian,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
#
# Functional tests for EmceeHammerMCMC
# Change point tests for EmceeHammerMCMC
#
# 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.
#
import pints
import pints.functionaltests as ft
import pints.cptests as cpt


def two_dim_gaussian(n_iterations=10000, n_warmup=1000):
Expand All @@ -17,9 +17,9 @@ def two_dim_gaussian(n_iterations=10000, n_warmup=1000):
``[0, 0]`` and returns a dictionary with entries ``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnTwoDimGaussian`.
:class:`pints.cptests.RunMcmcMethodOnTwoDimGaussian`.
"""
problem = ft.RunMcmcMethodOnTwoDimGaussian(
problem = cpt.RunMcmcMethodOnTwoDimGaussian(
_method, 10, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -34,9 +34,9 @@ def banana(n_iterations=10000, n_warmup=2000):
``[0, 0]`` and returns a dictionary with entries ``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnBanana`.
:class:`pints.cptests.RunMcmcMethodOnBanana`.
"""
problem = ft.RunMcmcMethodOnBanana(
problem = cpt.RunMcmcMethodOnBanana(
_method, 10, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -52,9 +52,9 @@ def correlated_gaussian(n_iterations=8000, n_warmup=4000):
``kld`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnCorrelatedGaussian`.
:class:`pints.cptests.RunMcmcMethodOnCorrelatedGaussian`.
"""
problem = ft.RunMcmcMethodOnCorrelatedGaussian(
problem = cpt.RunMcmcMethodOnCorrelatedGaussian(
_method, 10, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -69,9 +69,9 @@ def annulus(n_iterations=4000, n_warmup=2000):
dictionary with entries ``distance`` and ``mean-ess``.

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnAnnulus`.
:class:`pints.cptests.RunMcmcMethodOnAnnulus`.
"""
problem = ft.RunMcmcMethodOnAnnulus(
problem = cpt.RunMcmcMethodOnAnnulus(
_method, 10, n_iterations, n_warmup)
return {
'distance': problem.estimate_distance(),
Expand All @@ -87,9 +87,9 @@ def multimodal_gaussian(n_iterations=10000, n_warmup=1000):
"kld" and "mean-ess".

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnMultimodalGaussian`.
:class:`pints.cptests.RunMcmcMethodOnMultimodalGaussian`.
"""
problem = ft.RunMcmcMethodOnMultimodalGaussian(
problem = cpt.RunMcmcMethodOnMultimodalGaussian(
_method, 10, n_iterations, n_warmup)
return {
'kld': problem.estimate_kld(),
Expand All @@ -104,9 +104,9 @@ def cone(n_iterations=10000, n_warmup=1000):
a dict with entries "distance" and "mean-ess".

For details of the solved problem, see
:class:`pints.functionaltests.RunMcmcMethodOnCone`.
:class:`pints.cptests.RunMcmcMethodOnCone`.
"""
problem = ft.RunMcmcMethodOnCone(
problem = cpt.RunMcmcMethodOnCone(
_method, 10, n_iterations, n_warmup)
return {
'distance': problem.estimate_distance(),
Expand All @@ -115,7 +115,7 @@ def cone(n_iterations=10000, n_warmup=1000):


_method = pints.EmceeHammerMCMC
_functional_tests = [
_change_point_tests = [
annulus,
banana,
cone,
Expand Down
Loading