From bc50ca0c6708112d334f0dda9a7cf0f9a1f3159e Mon Sep 17 00:00:00 2001
From: kohlhaasrebecca <rebecca.kohlhaas@outlook.com>
Date: Wed, 9 Oct 2024 12:17:21 +0200
Subject: [PATCH] [tests] Add some PCE PostProcessing tests

---
 .../post_processing/post_processing.py        | 43 +++++++++++++++++++
 tests/test_PostProcessing.py                  | 11 +++++
 2 files changed, 54 insertions(+)

diff --git a/src/bayesvalidrox/post_processing/post_processing.py b/src/bayesvalidrox/post_processing/post_processing.py
index 3e75c08b1..e13ebf62d 100644
--- a/src/bayesvalidrox/post_processing/post_processing.py
+++ b/src/bayesvalidrox/post_processing/post_processing.py
@@ -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']))
diff --git a/tests/test_PostProcessing.py b/tests/test_PostProcessing.py
index a57e8c085..47de2f8a4 100644
--- a/tests/test_PostProcessing.py
+++ b/tests/test_PostProcessing.py
@@ -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
-- 
GitLab