From 404c525d6512e6872f1086036ee098ec89dec0f5 Mon Sep 17 00:00:00 2001 From: ejhigson <18406298+ejhigson@users.noreply.github.com> Date: Tue, 6 Aug 2019 18:07:39 +0100 Subject: [PATCH] updating tests --- tests/tests.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/tests.py b/tests/tests.py index 747b666..7c69ae9 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -50,9 +50,9 @@ UserWarning) if PYPOLYCHORD_AVAIL: try: - # If PolyChord is installed with MPI, we need to initialise mpi4py in order - # to run it multiple times from within the same python process without - # having an error. + # If PolyChord is installed with MPI, we need to initialise mpi4py in + # order to run it multiple times from within the same python process + # without having an error. # pylint: disable=unused-import from mpi4py import MPI # Initialize MPI except ImportError: @@ -258,7 +258,8 @@ def test_dynamic_param(self): dyPolyChord.run_dypolychord( self.run_func, dynamic_goal, self.settings, init_step=self.ninit, ninit=self.ninit, - nlive_const=self.nlive_const, stats_means_errs=False) + nlive_const=self.nlive_const, stats_means_errs=False, + clean=False) # Check the mean value using the posteriors file (its hard to make a # dummy run_func which is realistic enough to not fail checks if we try # loading the output normally with @@ -269,6 +270,22 @@ def test_dynamic_param(self): p1_mean = (np.sum(posteriors[:, 2] * posteriors[:, 0]) / np.sum(posteriors[:, 0])) self.assertAlmostEqual(p1_mean, 0.614126384660822, places=12) + # Test running with resume_dyn_run=True + dyPolyChord.run_dypolychord( + self.run_func, dynamic_goal, self.settings, + init_step=self.ninit, ninit=self.ninit, + nlive_const=self.nlive_const, stats_means_errs=False, + clean=False, resume_dyn_run=True) + # Test trying to resume when not all the required files are present + root = os.path.join(self.settings['base_dir'], + self.settings['file_root']) + os.remove(root + '_dyn_info.pkl') + dyPolyChord.run_dypolychord( + self.run_func, dynamic_goal, self.settings, + init_step=self.ninit, ninit=self.ninit, + nlive_const=self.nlive_const, stats_means_errs=False, + clean=False, resume_dyn_run=True) + def test_comm(self): """Test run_dyPolyChord's comm argument, which is used for running