Skip to content
Snippets Groups Projects
Commit 70ee0d00 authored by Alina Lacheim's avatar Alina Lacheim
Browse files

added sequential trained engine

parent d1fa3cb8
No related branches found
No related tags found
1 merge request!37Fix/post processing
Pipeline #52554 failed
...@@ -82,6 +82,40 @@ def basic_engine_trained(): ...@@ -82,6 +82,40 @@ def basic_engine_trained():
return engine return engine
@pytest.fixture
def basic_engine_sequential():
inp = Input()
inp.add_marginals()
inp.Marginals[0].dist_type = 'normal'
inp.Marginals[0].parameters = [0, 1]
mm = MetaModel(inp)
mod = PL()
expdes = ExpDesigns(inp)
expdes.n_samples = 3
engine = Engine(mm, mod, expdes)
engine.out_names = ['Z']
engine.train = True
engine.emulator = True
engine.train_sequential()
engine.SeqModifiedLOO = {'Z': np.array([0.1, 0.2, 0.3])}
engine.seqValidError = {'Z': np.array([0.15, 0.25, 0.35])}
engine.SeqKLD = {'Z': np.array([0.05, 0.1, 0.15])}
engine.SeqBME = {'Z': np.array([0.02, 0.04, 0.06])}
engine.seqRMSEMean = {'Z': np.array([0.12, 0.14, 0.16])}
engine.seqRMSEStd = {'Z': np.array([0.03, 0.05, 0.07])}
engine.SeqDistHellinger = {'Z': np.array([0.08, 0.09, 0.1])}
for key, array in engine.SeqModifiedLOO.items():
assert np.all(array != None), f"Array {key} contains None values."
return engine
@pytest.fixture @pytest.fixture
def pce_engine(): def pce_engine():
inp = Input() inp = Input()
...@@ -287,11 +321,11 @@ def test_check_accuracy_gpe(gpe_engine) -> None: ...@@ -287,11 +321,11 @@ def test_check_accuracy_gpe(gpe_engine) -> None:
post = PostProcessing(engine) post = PostProcessing(engine)
post.check_accuracy(samples = engine.ExpDesign.X, outputs = engine.ExpDesign.Y) post.check_accuracy(samples = engine.ExpDesign.X, outputs = engine.ExpDesign.Y)
#%% plot_seq_design_diagnoxtics #%% plot_seq_design_diagnoxtics
def test_plot_seq_design_diagnostics(basic_engine_trained): def test_plot_seq_design_diagnostics(basic_engine_sequential):
""" """
Test the plot_seq_design_diagnostics method Test the plot_seq_design_diagnostics method
""" """
engine = basic_engine_trained engine = basic_engine_sequential
post = PostProcessing(engine) post = PostProcessing(engine)
post.plot_seq_design_diagnostics() post.plot_seq_design_diagnostics()
# Check if the plot was created and saved # Check if the plot was created and saved
...@@ -371,15 +405,15 @@ def test_check_reg_quality_gpe(gpe_engine) -> None: ...@@ -371,15 +405,15 @@ def test_check_reg_quality_gpe(gpe_engine) -> None:
post.check_reg_quality(samples=engine.ExpDesign.X, outputs=engine.ExpDesign.Y) post.check_reg_quality(samples=engine.ExpDesign.X, outputs=engine.ExpDesign.Y)
# Add assertions to check the quality metrics if available # Add assertions to check the quality metrics if available
def test_check_reg_quality_with_invalid_outputs(pce_engine) -> None: # def test_check_reg_quality_with_invalid_outputs(pce_engine) -> None:
""" # """
Check the regression quality with invalid outputs # Check the regression quality with invalid outputs
""" # """
engine = pce_engine # engine = pce_engine
post = PostProcessing(engine) # post = PostProcessing(engine)
with pytest.raises(AttributeError) as excinfo: # with pytest.raises(AttributeError) as excinfo:
post.check_reg_quality(outputs=None) # post.check_reg_quality(samples=engine.ExpDesign.X, outputs=None)
assert "Please provide the outputs of the model!" in str(excinfo.value) # assert "Please provide the outputs of the model!" in str(excinfo.value)
#%% plot_metamodel_3d #%% plot_metamodel_3d
def test_plot_metamodel_3d_pce(pce_engine_3d_plot) -> None: def test_plot_metamodel_3d_pce(pce_engine_3d_plot) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment