From 232d1e98ac8a316b8479d125e0b1ace763b3bdb6 Mon Sep 17 00:00:00 2001 From: David Coster Date: Mon, 4 Dec 2023 16:34:03 +0100 Subject: [PATCH] drop a nuisance field from the params --- tests/test_surrogate_workflow.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_surrogate_workflow.py b/tests/test_surrogate_workflow.py index 323df998..f47df946 100644 --- a/tests/test_surrogate_workflow.py +++ b/tests/test_surrogate_workflow.py @@ -9,7 +9,7 @@ from tests.sc.sobol_model import sobol_g_func from easyvvuq.analysis.sc_analysis import SCAnalysisResults from easyvvuq.actions import CreateRunDirectory, Encode, Decode, ExecuteLocal, Actions, ExecutePython - +import matplotlib.pyplot as plt VARY = { "Pe": cp.Uniform(100.0, 200.0), @@ -17,7 +17,7 @@ } -@pytest.mark.skip(reason="Broke due to pandas update. See issue #395.") +###@pytest.mark.skip(reason="Broke due to pandas update. See issue #395.") @pytest.mark.parametrize('sampler', [ uq.sampling.RandomSampler( vary=VARY, max_num=100, analysis_class=uq.analysis.GaussianProcessSurrogate), @@ -72,6 +72,7 @@ def test_surrogate_workflow(tmpdir, sampler): assert np.max(np.abs(surrogate_y - model_y)) < 1e-6 # Attempt callibration with MCMC + del params['out_file'] # eliminate this (now) nuisance field campaign.add_app(name='surrogate', params=params, actions=Actions(ExecutePython(surrogate))) db_location = campaign.db_location campaign = None @@ -145,6 +146,7 @@ def proposal(x): def loglikelihood(x): return -((u - x) ** 2).sum() + init = {'Pe': [110.0], 'f': [2.0]} reloaded_campaign.set_sampler(uq.sampling.MCMCSampler(init, proposal, 'u', 1, loglikelihood)) iterator = reloaded_campaign.iterate(mark_invalid=True) @@ -154,3 +156,7 @@ def loglikelihood(x): assert (len(df) > 0) assert (len(df) <= 100) results = reloaded_campaign.analyse() + plt.clf(); results.plot_hist('Pe'); plt.savefig('/tmp/test_mcmc_hist_Pe.png') + plt.clf(); results.plot_hist('f'); plt.savefig('/tmp/test_mcmc_hist_f.png') + plt.clf(); results.plot_chains('Pe'); plt.savefig('/tmp/test_mcmc_chains_Pe.png') + plt.clf(); results.plot_chains('f'); plt.savefig('/tmp/test_mcmc_chains_f.png')