diff --git a/.gitignore b/.gitignore index 9cbc5104eeff861dda9a93d9c35260b654c33893..3b43b0c9d3a1c81d99c09ea3e33a06bce95d814c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,7 @@ Outputs_* *_env/* # Ignore test results -.coverage* \ No newline at end of file +.coverage* + +# Ignore files for vscode +.vscode/* \ No newline at end of file diff --git a/src/bayesvalidrox/post_processing/post_processing.py b/src/bayesvalidrox/post_processing/post_processing.py index c7b8bf98e70124102c88b7f62d3880b671fc7372..d3ece3e668a91c46060afaa9a62e006e20c879dd 100644 --- a/src/bayesvalidrox/post_processing/post_processing.py +++ b/src/bayesvalidrox/post_processing/post_processing.py @@ -1,27 +1,28 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import numpy as np import math import os from itertools import combinations, cycle +import numpy as np import pandas as pd -import scipy.stats as stats +from scipy import stats from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error, r2_score import matplotlib.pyplot as plt -import matplotlib.ticker as ticker +from matplotlib import ticker from matplotlib.offsetbox import AnchoredText from matplotlib.patches import Patch # Load the mplstyle plt.style.use(os.path.join(os.path.split(__file__)[0], '../', 'bayesvalidrox.mplstyle')) + class PostProcessing: """ This class provides many helper functions to post-process the trained meta-model. - + Parameters ---------- engine : obj @@ -31,22 +32,34 @@ class PostProcessing: The default is 'calib'. out_dir : string Output directory in which the images are placed. The default is ''. - + """ - def __init__(self, engine, name='calib', out_dir = ''): + def __init__(self, engine, name='calib', out_dir=''): self.engine = engine self.name = name - - self.out_dir = f'{out_dir}/Outputs_PostProcessing_{self.name}/' - + + self.out_dir = f'./{out_dir}/Outputs_PostProcessing_{self.name}/' + # Open a pdf for the plots if not os.path.exists(self.out_dir): os.makedirs(self.out_dir) + # Initialize attributes + self.mc_reference = None + self.total_sobol = None + self.valid_error = None + self.rmse = None + self.model_out_dict = {} + self.means = None + self.stds = None + + # TODO: Check if these could be removed! + self.pce_out_mean = None + self.pce_out_std = None # ------------------------------------------------------------------------- - def plot_moments(self, xlabel:str='Time [s]', plot_type:str=None): + def plot_moments(self, xlabel: str = 'Time [s]', plot_type: str = None): """ Plots the moments in a pdf format in the directory `Outputs_PostProcessing`. @@ -89,7 +102,7 @@ class PostProcessing: std_data = self.stds[key] # Extract a list of x values - if type(x_values_orig) is dict: + if isinstance(x_values_orig, dict): x = x_values_orig[key] else: x = x_values_orig @@ -140,15 +153,15 @@ class PostProcessing: # save the current figure fig.savefig( - f'./{self.out_dir}Mean_Std_PCE_{key}.pdf', + f'{self.out_dir}Mean_Std_PCE_{key}.pdf', bbox_inches='tight' - ) + ) return self.means, self.stds # ------------------------------------------------------------------------- def valid_metamodel(self, n_samples=1, samples=None, model_out_dict=None, - x_axis='Time [s]')-> None: + x_axis='Time [s]') -> None: """ Evaluates and plots the meta model and the PCEModel outputs for the given number of samples or the given samples. @@ -167,10 +180,9 @@ class PostProcessing: """ if samples is None: - self.n_samples = n_samples - samples = self._get_sample() + samples = self._get_sample(n_samples) else: - self.n_samples = samples.shape[0] + n_samples = samples.shape[0] # Extract x_values x_values = self.engine.ExpDesign.x_values @@ -179,7 +191,8 @@ class PostProcessing: self.model_out_dict = model_out_dict else: self.model_out_dict = self._eval_model(samples, key_str='valid') - self.pce_out_mean, self.pce_out_std = self.engine.eval_metamodel(samples) + self.pce_out_mean, self.pce_out_std = self.engine.eval_metamodel( + samples) try: key = self.engine.out_names[1] @@ -189,15 +202,16 @@ class PostProcessing: n_obs = self.model_out_dict[key].shape[1] if n_obs == 1: - self._plot_validation() + self._plot_validation(samples) else: self._plot_validation_multi(x_values=x_values, x_axis=x_axis) - + # Zip the subdirectories - self.engine.Model.zip_subdirs(f'{self.engine.Model.name}valid', f'{self.engine.Model.name}valid_') + self.engine.Model.zip_subdirs( + f'{self.engine.Model.name}valid', f'{self.engine.Model.name}valid_') # ------------------------------------------------------------------------- - def check_accuracy(self, n_samples=None, samples=None, outputs=None)-> None: + def check_accuracy(self, n_samples=None, samples=None, outputs=None) -> None: """ Checks accuracy of the metamodel by computing the root mean square error and validation error for all outputs. @@ -214,35 +228,31 @@ class PostProcessing: Raises ------ - Exception + AttributeError When neither n_samples nor samples are provided. """ # Set the number of samples - if n_samples: - self.n_samples = n_samples - elif samples is not None: - self.n_samples = samples.shape[0] - else: - raise Exception("Please provide either samples or pass the number" + if samples is None and n_samples is None: + raise AttributeError("Please provide either samples or pass the number" " of samples!") + n_samples = samples.shape[0] if samples is not None else n_samples # Generate random samples if necessary - samples = self._get_sample() if samples is None else samples + samples = self._get_sample(n_samples) if samples is None else samples # Run the original model with the generated samples - if outputs is None: - outputs = self._eval_model(samples, key_str='validSet') + outputs = self._eval_model(samples, key_str='validSet') if outputs is None else outputs # Run the PCE model with the generated samples - pce_outputs, _ = self.engine.eval_metamodel(samples) + metamod_outputs, _ = self.engine.eval_metamodel(samples) self.rmse = {} self.valid_error = {} # Loop over the keys and compute RMSE error. for key in self.engine.out_names: # Root mena square - self.rmse[key] = mean_squared_error(outputs[key], pce_outputs[key], + self.rmse[key] = mean_squared_error(outputs[key], metamod_outputs[key], squared=False, multioutput='raw_values') # Validation error @@ -250,7 +260,7 @@ class PostProcessing: np.var(outputs[key], ddof=1, axis=0) # Print a report table - print("\n>>>>> Errors of {} <<<<<".format(key)) + print(f"\n>>>>> Errors of {key} <<<<<") print("\nIndex | RMSE | Validation Error") print('-'*35) print('\n'.join(f'{i+1} | {k:.3e} | {j:.3e}' for i, (k, j) @@ -260,9 +270,8 @@ class PostProcessing: self.engine.MetaModel.rmse = self.rmse self.engine.MetaModel.valid_error = self.valid_error - # ------------------------------------------------------------------------- - def plot_seq_design_diagnostics(self, ref_BME_KLD=None)->None: + def plot_seq_design_diagnostics(self, ref_BME_KLD=None) -> None: """ Plots the Bayesian Model Evidence (BME) and Kullback-Leibler divergence (KLD) for the sequential design. @@ -382,7 +391,8 @@ class PostProcessing: ls='--', lw=2) # Plot each UtilFuncs - labels = np.arange(n_init_samples, n_total_samples+1, step1) + labels = np.arange( + n_init_samples, n_total_samples+1, step1) draw_plot(all_errors[:, ::step2], labels, edge_color, fill_color, idx) @@ -401,7 +411,7 @@ class PostProcessing: label=util)) plt.legend(handles=legend_elements[::-1], loc='best') - if plot != 'BME' and plot != 'KLD': + if plot not in ['BME','KLD']: plt.yscale('log') plt.autoscale(True) plt.xlabel('\\# of training samples') @@ -413,7 +423,7 @@ class PostProcessing: fig.savefig( f'./{newpath}/seq_{plot_name}.pdf', bbox_inches='tight' - ) + ) # Destroy the current plot plt.close() # Save arrays into files @@ -431,7 +441,7 @@ class PostProcessing: if n_total_samples not in x_idx: x_idx = np.hstack((x_idx, n_total_samples)) - if plot == 'KLD' or plot == 'BME': + if plot in ['KLD', 'BME']: # BME convergence if refBME is provided if ref_BME_KLD is not None: if plot == 'BME': @@ -472,8 +482,8 @@ class PostProcessing: seq_values = np.nan_to_num(seq_values) # Plot the error evolution for each output - #print(x_idx.shape) - #print(seq_values.mean(axis=1).shape) + # print(x_idx.shape) + # print(seq_values.mean(axis=1).shape) plt.semilogy(x_idx, seq_values.mean(axis=1), marker=markers[idx], ls='--', lw=2, color=colors[idx], @@ -499,17 +509,16 @@ class PostProcessing: fig.savefig( f'./{newpath}/seq_{plot_name}.pdf', bbox_inches='tight' - ) + ) # Destroy the current plot plt.close() # ---------------- Saving arrays into files --------------- np.save(f'./{newpath}/seq_{plot_name}.npy', seq_values) - return # ------------------------------------------------------------------------- - def sobol_indices(self, xlabel:str='Time [s]', plot_type:str=None): + def sobol_indices(self, xlabel: str = 'Time [s]', plot_type: str = None): """ Provides Sobol indices as a sensitivity measure to infer the importance of the input parameters. See Eq. 27 in [1] for more details. For the @@ -537,7 +546,7 @@ class PostProcessing: ------ AttributeError MetaModel in given Engine needs to be of type 'pce' or 'apce'. - + Returns ------- sobol_cell: dict @@ -547,22 +556,22 @@ class PostProcessing: """ # This function currently only supports PCE/aPCE - PCEModel = self.engine.MetaModel - if not hasattr(PCEModel, 'meta_model_type'): + metamod = self.engine.MetaModel + if not hasattr(metamod, 'meta_model_type'): raise AttributeError('Sobol indices only support PCE-type models!') - if PCEModel.meta_model_type.lower() not in ['pce', 'apce']: + if metamod.meta_model_type.lower() not in ['pce', 'apce']: raise AttributeError('Sobol indices only support PCE-type models!') - + # Extract the necessary variables - basis_dict = PCEModel._basis_dict - coeffs_dict = PCEModel._coeffs_dict - n_params = PCEModel.ndim - max_order = np.max(PCEModel._pce_deg) + basis_dict = metamod._basis_dict + coeffs_dict = metamod._coeffs_dict + n_params = metamod.ndim + max_order = np.max(metamod._pce_deg) sobol_cell_b = {} total_sobol_b = {} cov_Z_p_q = np.zeros((n_params)) - for b_i in range(PCEModel.n_bootstrap_itrs): + for b_i in range(metamod.n_bootstrap_itrs): sobol_cell_, total_sobol_ = {}, {} @@ -577,7 +586,8 @@ class PostProcessing: for i_order in range(1, max_order+1): n_comb = math.comb(n_params, i_order) - sobol_cell_array[i_order] = np.zeros((n_comb, n_meas_points)) + sobol_cell_array[i_order] = np.zeros( + (n_comb, n_meas_points)) total_sobol_array = np.zeros((n_params, n_meas_points)) @@ -590,7 +600,7 @@ class PostProcessing: Basis = basis_dict[f'b_{b_i+1}'][output][f'y_{pIdx+1}'] try: - clf_poly = PCEModel._clf_poly[f'b_{b_i+1}'][output][f'y_{pIdx+1}'] + clf_poly = metamod._clf_poly[f'b_{b_i+1}'][output][f'y_{pIdx+1}'] PCECoeffs = clf_poly.coef_ except: PCECoeffs = coeffs_dict[f'b_{b_i+1}'][output][f'y_{pIdx+1}'] @@ -610,9 +620,11 @@ class PostProcessing: else: nz_basis = Basis[nzidx] for i_order in range(1, max_order+1): - idx = np.where(np.sum(nz_basis > 0, axis=1) == i_order) + idx = np.where( + np.sum(nz_basis > 0, axis=1) == i_order) subbasis = nz_basis[idx] - Z = np.array(list(combinations(range(n_params), i_order))) + Z = np.array( + list(combinations(range(n_params), i_order))) for q in range(Z.shape[0]): Zq = Z[q] @@ -622,7 +634,8 @@ class PostProcessing: if TotalVariance[pIdx] == 0.0: sobol_cell_array[i_order][q, pIdx] = 0.0 else: - sobol = np.sum(np.square(PCECoeffs[sum_ind])) + sobol = np.sum( + np.square(PCECoeffs[sum_ind])) sobol /= TotalVariance[pIdx] sobol_cell_array[i_order][q, pIdx] = sobol @@ -639,20 +652,22 @@ class PostProcessing: total_sobol_array[ParIdx, pIdx] = sobol # ----- if PCA selected: Compute covariance ----- - if PCEModel.dim_red_method.lower() == 'pca': + if metamod.dim_red_method.lower() == 'pca': # Extract the basis indices (alpha) and coefficients for # next component if pIdx < n_meas_points-1: nextBasis = basis_dict[f'b_{b_i+1}'][output][f'y_{pIdx+2}'] - if PCEModel.bootstrap_method != 'fast' or b_i == 0: - clf_poly = PCEModel._clf_poly[f'b_{b_i+1}'][output][f'y_{pIdx+2}'] + if metamod.bootstrap_method != 'fast' or b_i == 0: + clf_poly = metamod._clf_poly[f'b_{b_i+1}'][output][f'y_{pIdx+2}'] nextPCECoeffs = clf_poly.coef_ else: nextPCECoeffs = coeffs_dict[f'b_{b_i+1}'][output][f'y_{pIdx+2}'] # Choose the common non-zero basis - mask = (Basis[:, None] == nextBasis).all(-1).any(-1) - n_mask = (nextBasis[:, None] == Basis).all(-1).any(-1) + mask = (Basis[:, None] == + nextBasis).all(-1).any(-1) + n_mask = (nextBasis[:, None] == + Basis).all(-1).any(-1) # Compute the covariance in Eq 17. for ParIdx in range(n_params): @@ -661,14 +676,14 @@ class PostProcessing: try: cov_Z_p_q[ParIdx] += np.sum(np.dot( PCECoeffs[idx], nextPCECoeffs[n_idx]) - ) + ) except: pass # Compute the sobol indices according to Ref. 2 - if PCEModel.dim_red_method.lower() == 'pca': + if metamod.dim_red_method.lower() == 'pca': n_c_points = self.engine.ExpDesign.Y[output].shape[1] - PCA = PCEModel.pca[f'b_{b_i+1}'][output] + PCA = metamod.pca[f'b_{b_i+1}'][output] compPCA = PCA.components_ nComp = compPCA.shape[0] var_Z_p = PCA.explained_variance_ @@ -677,7 +692,8 @@ class PostProcessing: for i_order in range(1, max_order+1): n_comb = math.comb(n_params, i_order) sobol_array[i_order] = np.zeros((n_comb, n_c_points)) - Z = np.array(list(combinations(range(n_params), i_order))) + Z = np.array( + list(combinations(range(n_params), i_order))) # Loop over parameters for q in range(Z.shape[0]): @@ -703,7 +719,8 @@ class PostProcessing: # term2 *= compPCA[i+1, tIdx] # term2 *= 2 - sobol_array[i_order][q, tIdx] = term1 #+ term2 + sobol_array[i_order][q, + tIdx] = term1 # + term2 # Devide over total output variance Eq. 18 sobol_array[i_order][q, tIdx] /= var_Y_t @@ -714,7 +731,8 @@ class PostProcessing: S_Z_i = total_sobol_array[ParIdx] for tIdx in range(n_c_points): - var_Y_t = np.var(self.engine.ExpDesign.Y[output][:, tIdx]) + var_Y_t = np.var( + self.engine.ExpDesign.Y[output][:, tIdx]) if var_Y_t == 0.0: term1, term2 = 0.0, 0.0 else: @@ -730,7 +748,7 @@ class PostProcessing: * compPCA[i+1, tIdx] term2 *= 2 - total_sobol[ParIdx, tIdx] = term1 #+ term2 + total_sobol[ParIdx, tIdx] = term1 # + term2 # Devide over total output variance Eq. 18 total_sobol[ParIdx, tIdx] /= var_Y_t @@ -812,7 +830,7 @@ class PostProcessing: fig.savefig( f'./{self.out_dir}Sobol_indices_{output}.pdf', bbox_inches='tight' - ) + ) # Destroy the current plot plt.close() @@ -820,7 +838,7 @@ class PostProcessing: return self.total_sobol # ------------------------------------------------------------------------- - def check_reg_quality(self, n_samples:int=1000, samples=None, outputs:dict=None)->None: + def check_reg_quality(self, n_samples: int = 1000, samples=None, outputs: dict = None) -> None: """ """ """ @@ -840,15 +858,14 @@ class PostProcessing: """ if samples is None: - self.n_samples = n_samples - samples = self._get_sample() + samples = self._get_sample(n_samples) else: - self.n_samples = samples.shape[0] + n_samples = samples.shape[0] # Evaluate the original and the surrogate model if outputs is None: y_val = self._eval_model(samples, key_str='valid') - else: + else: y_val = outputs y_pce_val, _ = self.engine.eval_metamodel(samples=samples) @@ -940,11 +957,11 @@ class PostProcessing: plt.close() # ------------------------------------------------------------------------- - def plot_metamodel_3d(self, n_samples = 10): + def plot_metamodel_3d(self, n_samples=10): """ Visualize the results of a PCE MetaModel as a 3D surface over two input parameters. - + Parameters ---------- n_samples : int @@ -960,64 +977,67 @@ class PostProcessing: None. """ - if self.engine.ExpDesign.ndim !=2: - raise AttributeError('This function is only applicable if the MetaModel input dimension is 2.') + if self.engine.ExpDesign.ndim != 2: + raise AttributeError( + 'This function is only applicable if the MetaModel input dimension is 2.') samples = self.engine.ExpDesign.generate_samples(n_samples) - samples = np.sort(np.sort(samples, axis = 1), axis = 0) - mean, stdev = self.engine.eval_metamodel(samples = samples) - + samples = np.sort(np.sort(samples, axis=1), axis=0) + mean, stdev = self.engine.eval_metamodel(samples=samples) + if self.engine.emulator: title = 'MetaModel' else: title = 'Model' - X,Y = np.meshgrid(samples[:,0],samples[:,1]) + X, Y = np.meshgrid(samples[:, 0], samples[:, 1]) for name in self.engine.out_names: for t in range(mean[name].shape[1]): fig = plt.figure() ax = plt.axes(projection='3d') - ax.plot_surface(X, Y, np.atleast_2d(mean[name][:,t]), rstride=1, cstride=1, + ax.plot_surface(X, Y, np.atleast_2d(mean[name][:, t]), rstride=1, cstride=1, cmap='viridis', edgecolor='none') ax.set_title(title) ax.set_xlabel('$x_1$') ax.set_ylabel('$x_2$') ax.set_zlabel('$f(x_1,x_2)$') - + plt.grid() - + # save the figure to file fig.savefig(f'./{self.out_dir}/3DPlot_{title}_{name}{t}.pdf', - bbox_inches='tight') + bbox_inches='tight') plt.close(fig) - # ------------------------------------------------------------------------- - def _get_sample(self, n_samples=None): + + def _get_sample(self, n_samples): """ Generates random samples taken from the input parameter space. + Parameters + ---------- + n_samples : int + Number of samples to generate. + Returns ------- samples : array of shape (n_samples, n_params) Generated samples. """ - if n_samples is None: - n_samples = self.n_samples - self.samples = self.engine.ExpDesign.generate_samples( + samples = self.engine.ExpDesign.generate_samples( n_samples, sampling_method='random') - return self.samples + return samples # ------------------------------------------------------------------------- - def _eval_model(self, samples=None, key_str='Valid'): + def _eval_model(self, samples, key_str='Valid'): """ - Evaluates Forward Model for the given number of self.samples or given - samples. + Evaluates Forward Model on the given samples. Parameters ---------- - samples : array of shape (n_samples, n_params), optional - Samples to evaluate the model at. The default is None. + samples : array of shape (n_samples, n_params) + Samples to evaluate the model at. key_str : str, optional Key string pass to the model. The default is 'Valid'. @@ -1027,18 +1047,14 @@ class PostProcessing: Dictionary of results. """ - if samples is None: - samples = self._get_sample() - self.samples = samples - else: - self.n_samples = len(samples) - - model_outs, _ = self.engine.Model.run_model_parallel(samples, key_str=key_str) + samples = self._get_sample() + model_outs, _ = self.engine.Model.run_model_parallel( + samples, key_str=key_str) return model_outs # ------------------------------------------------------------------------- - def _plot_validation(self): + def _plot_validation(self, samples): """ Plots outputs for visual comparison of metamodel outputs with that of the (full) original model. @@ -1049,15 +1065,15 @@ class PostProcessing: """ # 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!') - + metamod = self.engine.MetaModel + if not hasattr(metamod, 'meta_model_type'): + raise AttributeError( + 'This evaluation only support PCE-type models!') + if metamod.meta_model_type.lower() not in ['pce', 'apce']: + raise AttributeError( + 'This evaluation only support PCE-type models!') # get the samples - x_val = self.samples y_pce_val = self.pce_out_mean y_val = self.model_out_dict @@ -1082,7 +1098,7 @@ class PostProcessing: # the total number of explanatory variables in the model # (not including the constant term) length_list = [] - for key, value in PCEModel._coeffs_dict['b_1'][key].items(): + for key, value in metamod._coeffs_dict['b_1'][key].items(): length_list.append(len(value)) n_predictors = min(length_list) n_samples = x_val.shape[0] @@ -1098,7 +1114,7 @@ class PostProcessing: plt.ylabel("Original Model") plt.xlabel("PCE Model") plt.grid() - + # save the current figure plot_name = key.replace(' ', '_') fig.savefig(f'./{self.out_dir}/Model_vs_PCEModel_{plot_name}.pdf', @@ -1119,7 +1135,7 @@ class PostProcessing: List of x values. The default is []. x_axis : str, optional Label of the x axis. The default is "x [m]". - + Raises ------ AttributeError: This evaluation only support PCE-type models! @@ -1130,11 +1146,13 @@ class PostProcessing: """ # 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!') + metamod = self.engine.MetaModel + if not hasattr(metamod, 'meta_model_type'): + raise AttributeError( + 'This evaluation only support PCE-type models!') + if metamod.meta_model_type.lower() not in ['pce', 'apce']: + raise AttributeError( + 'This evaluation only support PCE-type models!') # List of markers and colors color = cycle((['b', 'g', 'r', 'y', 'k'])) @@ -1142,7 +1160,7 @@ class PostProcessing: fig = plt.figure() # Plot the model vs PCE model - for keyIdx, key in enumerate(self.engine.out_names): + for _, key in enumerate(self.engine.out_names): y_pce_val = self.pce_out_mean[key] y_pce_val_std = self.pce_out_std[key] @@ -1153,18 +1171,18 @@ class PostProcessing: x = x_values for idx in range(y_val.shape[0]): - Color = next(color) - Marker = next(marker) + color_ = next(color) + marker_ = next(marker) - plt.plot(x, y_val[idx], color=Color, marker=Marker, - label='$Y_{%s}^M$'%(idx+1)) + plt.plot(x, y_val[idx], color=color_, marker=marker_, + label='$Y_{%s}^M$' % (idx+1)) - plt.plot(x, y_pce_val[idx], color=Color, marker=Marker, + plt.plot(x, y_pce_val[idx], color=color_, marker=marker_, linestyle='--', - label='$Y_{%s}^{PCE}$'%(idx+1)) + label='$Y_{%s}^{PCE}$' % (idx+1)) plt.fill_between(x, y_pce_val[idx]-1.96*y_pce_val_std[idx], y_pce_val[idx]+1.96*y_pce_val_std[idx], - color=Color, alpha=0.15) + color=color_, alpha=0.15) # Calculate the RMSE rmse = mean_squared_error(y_pce_val, y_val, squared=False) diff --git a/tests/test_PostProcessing.py b/tests/test_PostProcessing.py index ba905d6473a62b53182744d5f10e7836adc39c1e..5f63962be77dc3ffe65b3bc33f8d907fda8ec55d 100644 --- a/tests/test_PostProcessing.py +++ b/tests/test_PostProcessing.py @@ -158,16 +158,16 @@ def test_check_reg_quality_pce(pce_engine) -> None: post = PostProcessing(engine) post.check_reg_quality(samples=engine.ExpDesign.X, outputs=engine.ExpDesign.Y) -#%% eval_pce_model_3d +#%% eplot_metamodel_3d -def test_eval_pce_model_3d_nopce(basic_engine) -> None: +def test_plot_metamodel_3d_nopce(basic_engine) -> None: """ 3d eval of non-PCE metamodel """ engine = basic_engine post = PostProcessing(engine) with pytest.raises(AttributeError) as excinfo: - post.eval_pce_model_3d() + post.plot_metamodel_3d() assert str(excinfo.value) == 'This evaluation only support PCE-type models!' @@ -180,9 +180,10 @@ def test_plot_validation_nopce(basic_engine) -> None: Plot validation of non-PCE metamodel """ engine = basic_engine + samples = engine.ExpDesign.generate_samples(10,'random') post = PostProcessing(engine) with pytest.raises(AttributeError) as excinfo: - post._plot_validation() + post._plot_validation(samples) assert str(excinfo.value) == 'This evaluation only support PCE-type models!' #%% _plot_validation_multi