Skip to content
Snippets Groups Projects
Commit 5dd4eb2a authored by kohlhaasrebecca's avatar kohlhaasrebecca
Browse files

[test] Create test file for PostProcessing

parent 0be909a6
No related branches found
No related tags found
1 merge request!37Fix/post processing
# -*- coding: utf-8 -*-
"""
Test the PostProcessing class in bayesvalidrox.
Tests are available for the following functions
Class PostProcessing:
init
plot_moments
valid_metamodel
check_accuracy
plot_seq_design
sobol_indices
check_req_quality
eval_pce_model_3d
_get_sample
_eval_model
_plot_validation
_plot_validation_multi
"""
import sys
sys.path.append("../src/")
import numpy as np
import pytest
from bayesvalidrox.post_processing.post_processing import PostProcessing
from bayesvalidrox.surrogate_models.inputs import Input
from bayesvalidrox.surrogate_models.input_space import InputSpace
from bayesvalidrox.surrogate_models.exp_designs import ExpDesigns
from bayesvalidrox.surrogate_models.surrogate_models import MetaModel
from bayesvalidrox.surrogate_models.polynomial_chaos import PCE
from bayesvalidrox.pylink.pylink import PyLinkForwardModel as PL
from bayesvalidrox.surrogate_models.engine import Engine
@pytest.fixture
def basic_engine():
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)
engine = Engine(mm, mod, expdes)
return engine
@pytest.fixture
def pce_engine():
inp = Input()
inp.add_marginals()
inp.Marginals[0].dist_type = 'normal'
inp.Marginals[0].parameters = [0, 1]
expdes = ExpDesigns(inp)
expdes.init_param_space(max_deg=1)
expdes.X = np.array([[0], [1], [0.5]])
expdes.Y = {'Z': [[0.4], [0.5], [0.45]]}
mm = PCE(inp)
mm.fit(expdes.X, expdes.Y)
mod = PL()
engine = Engine(mm, mod, expdes)
return engine
#%% Test PostProcessing init
def test_postprocessing_noengine():
None
def test_postprocessing(basic_engine) -> None:
engine = basic_engine
PostProcessing(engine)
#%% plot_moments
#%% valid_metamodel
#%% check_accuracy
#%% plot_seq_design
#%% sobol_indices
#%% check_reg_quality
#%% eval_pce_model_3d
#%% _get_sample
#%% _eval_model
#%% plot_validation
#%% _plot_validation_multi
\ No newline at end of file
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