diff --git a/src/bayesvalidrox/post_processing/post_processing.py b/src/bayesvalidrox/post_processing/post_processing.py index 73df97ef2bdfe811c1545c5873a93b42e5667c80..31941207f190e62c27c216fa9e960068bc976d3e 100644 --- a/src/bayesvalidrox/post_processing/post_processing.py +++ b/src/bayesvalidrox/post_processing/post_processing.py @@ -933,7 +933,7 @@ class PostProcessing: # ------------------------------------------------------------------------- def plot_metamodel_3d(self, n_samples=10): """ - Visualize the results of a PCE MetaModel as a 3D surface over two input + Visualize the results of a MetaModel as a 3D surface over two input parameters. Parameters diff --git a/tests/test_PostProcessing.py b/tests/test_PostProcessing.py index 33589c2c481a79a6cb23b697103a3254d94a79f8..57610598f8d8512e1cf4432244f7a3df9b2fefbc 100644 --- a/tests/test_PostProcessing.py +++ b/tests/test_PostProcessing.py @@ -130,7 +130,8 @@ def pce_engine_3d_plot(): 'Z': [[0.4], [0.5], [0.3], [0.4]], 'Y': [[0.35], [0.45], [0.40], [0.38]] } - expdes.x_values = [0, 0] # Example x-values (could be used for visualization or plotting) + expdes.X = np.array([[0,0], [1,0], [0.5,0.3], [0.3,0.7]]) + expdes.x_values = [0] # Example x-values (could be used for visualization or plotting) # Create and fit the Polynomial Chaos Expansion model (PCE) mm = PCE(inp) # Initialize the PCE model @@ -144,11 +145,7 @@ def pce_engine_3d_plot(): engine.emulator = True # Indicate that the engine is emulating a trained model engine.trained = True # Mark the engine as trained - # Initialize the InputSpace (ensure this is defined correctly for your context) - mm.InputSpace = InputSpace(mm.input_obj, mm.meta_model_type) - return engine # Return the configured engine - return engine @pytest.fixture def gpe_engine(): @@ -409,18 +406,8 @@ def test_plot_metamodel_3d_pce(pce_engine_3d_plot) -> None: post = PostProcessing(engine) post.plot_metamodel_3d() # Check if the plot was created and saved - assert os.path.exists(f"./{engine.out_dir}/Metamodel_3D.{engine.out_format}") - -def test_plot_metamodel_3d_with_invalid_data(pce_engine_3d_plot) -> None: - """ - Test the plot_metamodel_3d method with invalid data - """ - engine = pce_engine_3d_plot - engine.ExpDesign.X = [] - post = PostProcessing(engine) - with pytest.raises(ValueError) as excinfo: - post.plot_metamodel_3d() - assert "Input data cannot be empty" in str(excinfo.value) + assert os.path.exists(f"./{post.out_dir}/3DPlot_MetaModel_Z0.{post.out_format}") + assert os.path.exists(f"./{post.out_dir}/3DPlot_MetaModel_Y0.{post.out_format}") #%% _plot_validation_multi only for PCE @@ -431,7 +418,7 @@ def test_plot_validation_multi(pce_engine_3d_plot): engine = pce_engine_3d_plot post = PostProcessing(engine) y_val = {'Z': [1, 2, 3, 4, 5]} - y_val_std = {'Y': [0.1, 0.2, 0.3, 0.4, 0.5]} + y_val_std = {'Z': [0.1, 0.2, 0.3, 0.4, 0.5]} post._plot_validation_multi(y_val, y_val_std) # Check if the plot was created and saved assert os.path.exists(f"./{engine.out_dir}/Model_vs_Model_key1.{engine.out_format}")