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

[tests] Add some PCE PostProcessing tests

parent 553c98ff
No related branches found
No related tags found
1 merge request!37Fix/post processing
......@@ -563,12 +563,21 @@ class PostProcessing:
"""
# This function currently only supports PCE/aPCE
<<<<<<< HEAD
metamod = self.engine.MetaModel
if not hasattr(metamod, 'meta_model_type'):
raise AttributeError('Sobol indices only support PCE-type models!')
if metamod.meta_model_type.lower() not in ['pce', 'apce']:
raise AttributeError('Sobol indices only support PCE-type models!')
=======
PCEModel = self.engine.MetaModel
if not hasattr(PCEModel, 'meta_model_type'):
raise AttributeError('Sobol indices only support PCE-type models!')
if PCEModel.meta_model_type.lower() not in ['pce', 'apce']:
raise AttributeError('Sobol indices only support PCE-type models!')
>>>>>>> a58a509a ([tests] Add some PCE PostProcessing tests)
# Extract the necessary variables
basis_dict = metamod._basis_dict
coeffs_dict = metamod._coeffs_dict
......@@ -966,6 +975,7 @@ class PostProcessing:
plt.close()
# -------------------------------------------------------------------------
<<<<<<< HEAD
def plot_metamodel_3d(self, n_samples=10):
"""
Visualize the results of a PCE MetaModel as a 3D surface over two input
......@@ -980,6 +990,18 @@ class PostProcessing:
------
AttributeError
This function is only applicable if the MetaModel input dimension is 2.
=======
def eval_pce_model_3d(self):
# This function currently only supports PCE/aPCE
PCEModel = self.engine.MetaModel
if not hasattr(PCEModel, 'meta_model_type'):
raise AttributeError('This evaluation only support PCE-type models!')
if PCEModel.meta_model_type.lower() not in ['pce', 'apce']:
raise AttributeError('This evaluation only support PCE-type models!')
self.n_samples = 1000
n_samples = self.n_samples
>>>>>>> a58a509a ([tests] Add some PCE PostProcessing tests)
Returns
-------
......@@ -1074,6 +1096,7 @@ class PostProcessing:
"""
# This function currently only supports PCE/aPCE
<<<<<<< HEAD
metamod = self.engine.MetaModel
if not hasattr(metamod, 'meta_model_type'):
raise AttributeError(
......@@ -1081,6 +1104,14 @@ class PostProcessing:
if metamod.meta_model_type.lower() not in ['pce', 'apce']:
raise AttributeError(
'This evaluation only support PCE-type models!')
=======
PCEModel = self.engine.MetaModel
if not hasattr(PCEModel, 'meta_model_type'):
raise AttributeError('This evaluation only support PCE-type models!')
if PCEModel.meta_model_type.lower() not in ['pce', 'apce']:
raise AttributeError('This evaluation only support PCE-type models!')
>>>>>>> a58a509a ([tests] Add some PCE PostProcessing tests)
# get the samples
y_pce_val = self.pce_out_mean
......@@ -1159,6 +1190,7 @@ class PostProcessing:
"""
# This function currently only supports PCE/aPCE
<<<<<<< HEAD
metamod = self.engine.MetaModel
if not hasattr(metamod, 'meta_model_type'):
raise AttributeError(
......@@ -1166,6 +1198,17 @@ class PostProcessing:
if metamod.meta_model_type.lower() not in ['pce', 'apce']:
raise AttributeError(
'This evaluation only support PCE-type models!')
=======
PCEModel = self.engine.MetaModel
if not hasattr(PCEModel, 'meta_model_type'):
raise AttributeError('This evaluation only support PCE-type models!')
if PCEModel.meta_model_type.lower() not in ['pce', 'apce']:
raise AttributeError('This evaluation only support PCE-type models!')
newpath = f'Outputs_PostProcessing_{self.name}/'
if not os.path.exists(newpath):
os.makedirs(newpath)
>>>>>>> a58a509a ([tests] Add some PCE PostProcessing tests)
# List of markers and colors
color = cycle((['b', 'g', 'r', 'y', 'k']))
......
......@@ -149,6 +149,7 @@ def test_sobol_indices_pce(pce_engine) -> None:
assert sobol['Z'][0,0] == 1
#%% check_reg_quality
<<<<<<< HEAD
def test_check_reg_quality_pce(pce_engine) -> None:
"""
......@@ -161,14 +162,24 @@ def test_check_reg_quality_pce(pce_engine) -> None:
#%% eplot_metamodel_3d
def test_plot_metamodel_3d_nopce(basic_engine) -> None:
=======
#%% eval_pce_model_3d
def test_eval_pce_model_3d_nopce(basic_engine) -> None:
>>>>>>> a58a509a ([tests] Add some PCE PostProcessing tests)
"""
3d eval of non-PCE metamodel
"""
engine = basic_engine
post = PostProcessing(engine)
with pytest.raises(AttributeError) as excinfo:
<<<<<<< HEAD
post.plot_metamodel_3d()
assert str(excinfo.value) == 'This function is only applicable if the MetaModel input dimension is 2.'
=======
post.eval_pce_model_3d()
assert str(excinfo.value) == 'This evaluation only support PCE-type models!'
>>>>>>> a58a509a ([tests] Add some PCE PostProcessing tests)
#%% _get_sample
......
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