From 6a1eb14e6d9065377aa80b0f33eb9a2fd7e64112 Mon Sep 17 00:00:00 2001 From: kohlhaasrebecca <rebecca.kohlhaas@outlook.com> Date: Fri, 28 Jun 2024 22:56:04 +0200 Subject: [PATCH] Undo botched rebase --- .coverage | Bin 0 -> 53248 bytes .idea/.gitignore | 8 +++ .idea/bayesvalidrox.iml | 18 +++++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 7 ++ .idea/modules.xml | 8 +++ .idea/other.xml | 6 ++ .idea/vcs.xml | 6 ++ CHANGELOG.md | 5 +- examples/.coverage | Bin 0 -> 53248 bytes .../example_analytical_function.py | 66 ++++++++++-------- .../bayes_inference/discrepancy.py | 16 ++++- .../surrogate_models/__init__.py | 9 ++- .../surrogate_models/desktop.ini | 2 + .../surrogate_models/exploration.py | 1 + src/bayesvalidrox/surrogate_models/inputs.py | 20 +++--- .../surrogate_models/reg_fast_ard.py | 2 +- tests/test_BayesModelComparison.py | 28 ++++++++ tests/test_Discrepancy.py | 18 +---- tests/test_ExpDesign.py | 49 ++++++++++--- tests/test_Input.py | 6 +- 21 files changed, 207 insertions(+), 74 deletions(-) create mode 100644 .coverage create mode 100644 .idea/.gitignore create mode 100644 .idea/bayesvalidrox.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/other.xml create mode 100644 .idea/vcs.xml create mode 100644 examples/.coverage create mode 100644 src/bayesvalidrox/surrogate_models/desktop.ini create mode 100644 tests/test_BayesModelComparison.py diff --git a/.coverage b/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..7bd62455cae2ec79af9cbc60f552afe43fca17d4 GIT binary patch literal 53248 zcmeI5e{>Vaoxn%ZTGHy*$jC-E25W887#d?BydI&U*aQ=B2z3$&Ns5D5OKVx6UuY$; zj|6*xK4`dHXwqv)lS1#GroFsga=o<SH4xm^>3g(EnqFUWd9PO>&RxR0OR&u)7pK_P zeP>oHOR`NHY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=Vj$G?X?0Kdhr<FmLApTR$YeE`qnXYqIO zKjNqH6R;QH5quaQ!256)PQZSE9azHK@m3JR4n}|xU<4QeMt~7u1Q-EEfDvE>7y(A$ zuZn=78eXk$s3L(t0uKo)NidHDb4gG^f;l88CqWqr+$5Myf>IKckibQPStKYXfs+K7 m1P&6|Nnj&^l>`<N@FXykz(fKg35rO-k-$I#JqgJB|NkH7vuQ#A literal 0 HcmV?d00001 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..13566b81b --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/bayesvalidrox.iml b/.idea/bayesvalidrox.iml new file mode 100644 index 000000000..fab03b6ec --- /dev/null +++ b/.idea/bayesvalidrox.iml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="PYTHON_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> + <component name="PyDocumentationSettings"> + <option name="format" value="NUMPY" /> + <option name="myDocStringFormat" value="NumPy" /> + </component> + <component name="TestRunnerService"> + <option name="PROJECT_TEST_RUNNER" value="py.test" /> + </component> +</module> \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..105ce2da2 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ +<component name="InspectionProjectProfileManager"> + <settings> + <option name="USE_PROJECT_PROFILE" value="false" /> + <version value="1.0" /> + </settings> +</component> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..a6218fed0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Black"> + <option name="sdkName" value="Python 3.11" /> + </component> + <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" /> +</project> \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..482c611f3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/bayesvalidrox.iml" filepath="$PROJECT_DIR$/.idea/bayesvalidrox.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 000000000..2e75c2e2a --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="PySciProjectComponent"> + <option name="PY_INTERACTIVE_PLOTS_SUGGESTED" value="true" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index be1a97712..42c974fb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # CHANGELOG -## v1.0.0 +## [Unreleased] ### Requirements -* updated for python 3.10 +* numpy now at 1.23.3 +* .... ### Added Features diff --git a/examples/.coverage b/examples/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..254e10e4371d703eefec0f0437f9c0575be3f5ec GIT binary patch literal 53248 zc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4kNyI~Ti{g+>+-ILdzNqJ2Ilh?UD zg<4C4)A0U0)Y_wEm6t7jDL*P!2U7Daq*p~Z42MbvW^JGtS2gA7X_1!U=&JPLBn`dK zY3$x#P0N%oE<DZOqCuCBFWT{a8T7LCikD%ND$V^oI5{6PiBLqbN`q3<5IvM;o@jQK zXRJK^%@LV!s=n-*;m(aRmEwbeI+C1OjjqU8#h$MO2T2Q)cB}_d3pY}9lGf6-)$+@_ z0k>9Xiy!$@@=1OxH(s%;t@G#Yagq&2GtYE1E$Y6^i=DkJ&2*AOCnx>o22Hs1ZfClm zu-y~~zce}U<Yrp1YZUTO*?XP(8h^mIo#z(aut5L<5P$##AOHafKmY;|fB*y_@ZS?C z+a<fopZ`nFAC~hMJz#?X1Rwwb2tWV=5P$##AOHafK;X?3Xq3ulo%}Bz?>csQxt0A1 z;JwX@n-}X;tCI87a-KSWznK+8sUZLX2tWV=5P$##AOHafKmY;|$ORhZvv&S1K&f6{ zu4P{WnE(Gjv79G)NIXLT0uX=z1Rwwb2tWV=5P$##AW)n@&t9;`*Dqgcf2HX<2<_-@ zI2aD3)a@&woA@e-b^8-9{xs>fyK-M?x&nmPi^9FO+LQihsC1hyqd_0?clnA$omgoK zfA|PpFM)smx1FCYx?zI=1Rwwb2tWV=5P$##AOHafK%jVm-op5L?ce_VkL&*x->}FL z0uX=z1Rwwb2tWV=5P$##AW)z{*)Cg6^ZWk`%Xv{?&d3S^5P$##AOHafKmY;|fB*y_ z0D-~;%H?Lw{Qm#Ua-J2IEi!@t1Rwwb2tWV=5P$##AOHafK%gLjioH;)o%+o-zyCkC zoaY5)jBFqP0SG_<0uX=z1Rwwb2tWV=5GYb$fxZDqfB&~m6`3vaf&c^{009U<00Izz z00bZa0SG{#XaWBHAD{n=R!4pifB*y_009U<00Izz00bZafno)4{r_UUksAac009U< W00Izz00bZa0SG{#V1e}d|Nj6bO?%Y< literal 0 HcmV?d00001 diff --git a/examples/analytical-function/example_analytical_function.py b/examples/analytical-function/example_analytical_function.py index f80767bef..bdf22598a 100644 --- a/examples/analytical-function/example_analytical_function.py +++ b/examples/analytical-function/example_analytical_function.py @@ -139,7 +139,7 @@ if __name__ == "__main__": # One-shot (normal) or Sequential Adaptive (sequential) Design ExpDesign.method = 'sequential' - ExpDesign.n_init_samples = 100#3*ndim + ExpDesign.n_init_samples = 140#00#3*ndim # Sampling methods # 1) random 2) latin_hypercube 3) sobol 4) halton 5) hammersley @@ -225,7 +225,8 @@ if __name__ == "__main__": MetaModelOpts.ExpDesign = ExpDesign engine = Engine(MetaModelOpts, Model, ExpDesign) engine.start_engine() - engine.train_sequential() + #engine.train_sequential() + engine.train_normal() # Load the objects # with open(f"PCEModel_{Model.name}.pkl", "rb") as input: @@ -264,12 +265,12 @@ if __name__ == "__main__": # BayesOpts.selected_indices = [0, 3, 5, 7, 9] # BME Bootstrap - # BayesOpts.bootstrap = True - # BayesOpts.n_bootstrap_itrs = 500 - # BayesOpts.bootstrap_noise = 100 + BayesOpts.bootstrap = True + BayesOpts.n_bootstrap_itrs = 500 + BayesOpts.bootstrap_noise = 100 # Bayesian cross validation - # BayesOpts.bayes_loocv = True + BayesOpts.bayes_loocv = True # TODO: test what this does # Select the inference method import emcee @@ -294,31 +295,34 @@ if __name__ == "__main__": BayesOpts.Discrepancy = DiscrepancyOpts # -- (Option C) -- - # DiscOutputOpts = Input() - # # # OutputName = 'Z' - # DiscOutputOpts.add_marginals() - # DiscOutputOpts.Marginals[0].Nnme = '$\sigma^2_{\epsilon}$' - # DiscOutputOpts.Marginals[0].dist_type = 'uniform' - # DiscOutputOpts.Marginals[0].parameters = [0, 10] - # BayesOpts.Discrepancy = {'known': DiscrepancyOpts, - # 'infer': Discrepancy(DiscOutputOpts)} - - # BayesOpts.bias_inputs = {'Z':np.arange(0, 10, 1.).reshape(-1,1) / 9} - # DiscOutputOpts = Input() - # # OutputName = 'lambda' - # DiscOutputOpts.add_marginals() - # DiscOutputOpts.Marginals[0].name = '$\lambda$' - # DiscOutputOpts.Marginals[0].dist_type = 'uniform' - # DiscOutputOpts.Marginals[0].parameters = [0, 1] - - # # OutputName = 'sigma_f' - # DiscOutputOpts.add_marginals() - # DiscOutputOpts.Marginals[1].Name = '$\sigma_f$' - # DiscOutputOpts.Marginals[1].dist_type = 'uniform' - # DiscOutputOpts.Marginals[1].parameters = [0, 1e-4] - # BayesOpts.Discrepancy = Discrepancy(DiscOutputOpts) - # BayesOpts.Discrepancy = {'known': DiscrepancyOpts, - # 'infer': Discrepancy(DiscOutputOpts)} + if 0: + DiscOutputOpts = Input() + # # # OutputName = 'Z' + DiscOutputOpts.add_marginals() + DiscOutputOpts.Marginals[0].Nnme = '$\sigma^2_{\epsilon}$' + DiscOutputOpts.Marginals[0].dist_type = 'uniform' + DiscOutputOpts.Marginals[0].parameters = [0, 10] + #BayesOpts.Discrepancy = {'known': DiscrepancyOpts, + # 'infer': Discrepancy(DiscOutputOpts)} + + BayesOpts.bias_inputs = {'Z':np.arange(0, 10, 1.).reshape(-1,1) / 9} + + DiscOutputOpts = Input() + # OutputName = 'lambda' + DiscOutputOpts.add_marginals() + DiscOutputOpts.Marginals[0].name = '$\lambda$' + DiscOutputOpts.Marginals[0].dist_type = 'uniform' + DiscOutputOpts.Marginals[0].parameters = [0, 1] + + # # OutputName = 'sigma_f' + DiscOutputOpts.add_marginals() + DiscOutputOpts.Marginals[1].Name = '$\sigma_f$' + DiscOutputOpts.Marginals[1].dist_type = 'uniform' + DiscOutputOpts.Marginals[1].parameters = [0, 1e-4] + #BayesOpts.Discrepancy = Discrepancy(DiscOutputOpts) + BayesOpts.Discrepancy = {'known': DiscrepancyOpts, + 'infer': Discrepancy(DiscOutputOpts)} + # Start the calibration/inference Bayes_PCE = BayesOpts.create_inference() diff --git a/src/bayesvalidrox/bayes_inference/discrepancy.py b/src/bayesvalidrox/bayes_inference/discrepancy.py index fff32a250..b3c235ebe 100644 --- a/src/bayesvalidrox/bayes_inference/discrepancy.py +++ b/src/bayesvalidrox/bayes_inference/discrepancy.py @@ -36,7 +36,7 @@ class Discrepancy: * Option B: With unknown redidual covariance matrix \\(\\Sigma\\), paramethrized as \\(\\Sigma(\\theta_{\\epsilon})=\\sigma^2 \\textbf{I}_ {N_{out}}\\) with unknown residual variances \\(\\sigma^2\\). - This term will be jointly infer with the uncertain input parameters. For + This term will be jointly infered with the uncertain input parameters. For the inversion, you need to define a prior marginal via `Input` class. Note that \\(\\sigma^2\\) is only a single scalar multiplier for the diagonal entries of the covariance matrix \\(\\Sigma\\). @@ -58,10 +58,17 @@ class Discrepancy: """ def __init__(self, InputDisc='', disc_type='Gaussian', parameters=None): + # Set the values self.InputDisc = InputDisc self.disc_type = disc_type self.parameters = parameters - + + # Other inits + self.ExpDesign = None + self.n_samples = None + self.sigma2_prior = None + self.name = None + self.opt_sigma = None # This will be set in the inference class and used in mcmc # ------------------------------------------------------------------------- def get_sample(self, n_samples): """ @@ -87,6 +94,11 @@ class Discrepancy: # Create and store BoundTuples self.ExpDesign = ExpDesigns(self.InputDisc) self.ExpDesign.sampling_method = 'random' + + # TODO: why does it call 'generate_ED' instead of 'generate_samples? + # ExpDesign.bound_tuples, onp_sigma, prior_space needed from the outside + # Discrepancy opt_sigma, InputDisc needed from the outside + # TODO: opt_sigma not defined here, but called from the outside?? self.ExpDesign.generate_ED( n_samples, max_pce_deg=1 ) diff --git a/src/bayesvalidrox/surrogate_models/__init__.py b/src/bayesvalidrox/surrogate_models/__init__.py index 70bfb20f5..6d8ce9f1c 100644 --- a/src/bayesvalidrox/surrogate_models/__init__.py +++ b/src/bayesvalidrox/surrogate_models/__init__.py @@ -1,7 +1,12 @@ # -*- coding: utf-8 -*- - +from .engine import Engine +from .exp_designs import ExpDesigns +from .input_space import InputSpace from .surrogate_models import MetaModel __all__ = [ - "MetaModel" + "MetaModel", + "InputSpace", + "ExpDesigns", + "Engine" ] diff --git a/src/bayesvalidrox/surrogate_models/desktop.ini b/src/bayesvalidrox/surrogate_models/desktop.ini new file mode 100644 index 000000000..632de13ae --- /dev/null +++ b/src/bayesvalidrox/surrogate_models/desktop.ini @@ -0,0 +1,2 @@ +[LocalizedFileNames] +exploration.py=@exploration.py,0 diff --git a/src/bayesvalidrox/surrogate_models/exploration.py b/src/bayesvalidrox/surrogate_models/exploration.py index 6abb652f1..67decae2b 100644 --- a/src/bayesvalidrox/surrogate_models/exploration.py +++ b/src/bayesvalidrox/surrogate_models/exploration.py @@ -33,6 +33,7 @@ class Exploration: def __init__(self, ExpDesign, n_candidate, mc_criterion='mc-intersite-proj-th'): + self.closestPoints = None self.ExpDesign = ExpDesign self.n_candidate = n_candidate self.mc_criterion = mc_criterion diff --git a/src/bayesvalidrox/surrogate_models/inputs.py b/src/bayesvalidrox/surrogate_models/inputs.py index 094e1066f..40ae36337 100644 --- a/src/bayesvalidrox/surrogate_models/inputs.py +++ b/src/bayesvalidrox/surrogate_models/inputs.py @@ -4,6 +4,7 @@ Inputs and related marginal distributions """ + class Input: """ A class to define the uncertain input parameters. @@ -20,17 +21,18 @@ class Input: ------- Marginals can be defined as following: - >>> Inputs.add_marginals() - >>> Inputs.Marginals[0].name = 'X_1' - >>> Inputs.Marginals[0].dist_type = 'uniform' - >>> Inputs.Marginals[0].parameters = [-5, 5] + >>> inputs = Inputs() + >>> inputs.add_marginals() + >>> inputs.Marginals[0].name = 'X_1' + >>> inputs.Marginals[0].dist_type = 'uniform' + >>> inputs.Marginals[0].parameters = [-5, 5] If there is no common data is avaliable, the input data can be given as following: - >>> Inputs.add_marginals() - >>> Inputs.Marginals[0].name = 'X_1' - >>> Inputs.Marginals[0].input_data = input_data + >>> inputs.add_marginals() + >>> inputs.Marginals[0].name = 'X_1' + >>> inputs.Marginals[0].input_data = [0,0,1,0] """ poly_coeffs_flag = True @@ -63,12 +65,12 @@ class Marginal: dist_type : string Name of the distribution. The default is `None`. parameters : list - List of the parameters corresponding to the distribution type. The + Parameters corresponding to the distribution type. The default is `None`. input_data : array Available input data. The default is `[]`. moments : list - List of the moments. + Moments of the distribution. The default is `None`. """ def __init__(self): diff --git a/src/bayesvalidrox/surrogate_models/reg_fast_ard.py b/src/bayesvalidrox/surrogate_models/reg_fast_ard.py index e6883a3ed..fdd0ee747 100755 --- a/src/bayesvalidrox/surrogate_models/reg_fast_ard.py +++ b/src/bayesvalidrox/surrogate_models/reg_fast_ard.py @@ -236,7 +236,7 @@ class RegressionFastARD(LinearModel, RegressorMixin): self.var_y = False A = np.PINF * np.ones(n_features) - active = np.zeros(n_features, dtype=np.bool) + active = np.zeros(n_features, dtype=bool) if self.start is not None and not hasattr(self, 'active_'): start = self.start diff --git a/tests/test_BayesModelComparison.py b/tests/test_BayesModelComparison.py new file mode 100644 index 000000000..91f328ec7 --- /dev/null +++ b/tests/test_BayesModelComparison.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +""" +Test the BayesModelComparison class in bayesvalidrox. +Tests are available for the following functions +Class BayesModelComparison: + create_model_comparison + compare_models + generate_dataset + __perturb_data + cal_model_weight + plot_just_analysis + plot_model_weights + plot_bayes_factor + +""" +import sys +sys.path.append("src/") +import pytest +import numpy as np + +from bayesvalidrox.bayes_inference.bayes_model_comparison import BayesModelComparison +#from bayesvalidrox.surrogate_models.input_space import InputSpace + +def test_BMC() -> None: + """ + Build BMC without inputs + """ + BayesModelComparison() \ No newline at end of file diff --git a/tests/test_Discrepancy.py b/tests/test_Discrepancy.py index c46e0a137..7fb948d90 100644 --- a/tests/test_Discrepancy.py +++ b/tests/test_Discrepancy.py @@ -36,22 +36,8 @@ def test_get_sample() -> None: """ Get discrepancy sample """ - inp = Input() - inp.add_marginals() - inp.Marginals[0].dist_type = 'normal' - inp.Marginals[0].parameters = [0,1] - disc = Discrepancy(InputDisc = inp) + disc = Discrepancy() with pytest.raises(AttributeError) as excinfo: disc.get_sample(2) assert str(excinfo.value) == 'Cannot create new samples, please provide input distributions' - - - - -if __name__ == '__main__': - inp = Input() - inp.add_marginals() - inp.Marginals[0].dist_type = 'normal' - inp.Marginals[0].parameters = [0,1] - disc = Discrepancy(InputDisc = inp) - disc.get_sample(2) \ No newline at end of file + \ No newline at end of file diff --git a/tests/test_ExpDesign.py b/tests/test_ExpDesign.py index 3da00d32e..0a1191799 100644 --- a/tests/test_ExpDesign.py +++ b/tests/test_ExpDesign.py @@ -135,6 +135,47 @@ def test_random_sampler() -> None: exp = ExpDesigns(inp) exp.random_sampler(4) +def test_random_sampler_largedatanoJDist() -> None: + """ + Sample randomly, init_param_space implicitly, more samples wanted than given, no JDist available + """ + x = np.random.uniform(0,1,1000) + inp = Input() + inp.add_marginals() + inp.Marginals[0].input_data = x + exp = ExpDesigns(inp) + with pytest.raises(AttributeError) as excinfo: + exp.random_sampler(100000) + assert str(excinfo.value) == 'Sampling cannot proceed, build ExpDesign with max_deg != 0 to create JDist!' + +def test_random_sampler_largedataJDist0() -> None: + """ + Sample randomly, init_param_space implicitly, more samples wanted than given, + JDist available, priors given via samples + """ + x = np.random.uniform(0,1,1000) + inp = Input() + inp.add_marginals() + inp.Marginals[0].input_data = x + exp = ExpDesigns(inp) + exp.init_param_space(max_deg = 1) + exp.random_sampler(100000) + +def test_random_sampler_largedataJDist1() -> None: + """ + Sample randomly, init_param_space implicitly, more samples wanted than given, + JDist available, prior distributions given + """ + inp = Input() + inp.add_marginals() + inp.Marginals[0].dist_type = 'normal' + inp.Marginals[0].parameters = [0,1] + exp = ExpDesigns(inp) + exp.init_param_space(max_deg = 1) + exp.random_sampler(100000) + + + def test_random_sampler_rawdata() -> None: """ Sample randomly, init_param_space implicitly, has 2d raw data @@ -374,11 +415,3 @@ def test_read_from_file(): exp = ExpDesigns(inp, sampling_method = 'user') exp.hdf5_file = 'tests/ExpDesign_testfile.hdf5' exp.read_from_file(['Z']) - -if __name__ == '__main__': - x = np.random.uniform(0,1,1000) - inp = Input() - inp.add_marginals() - inp.Marginals[0].input_data = x - exp = ExpDesigns(inp, sampling_method = 'PCM') - exp.generate_ED(4) \ No newline at end of file diff --git a/tests/test_Input.py b/tests/test_Input.py index 84b9b239c..41c0e5ab8 100644 --- a/tests/test_Input.py +++ b/tests/test_Input.py @@ -9,10 +9,10 @@ Class Input: @author: Rebecca Kohlhaas """ import sys -sys.path.append("src/") -import pytest -from bayesvalidrox.surrogate_models.inputs import Marginal, Input +from bayesvalidrox.surrogate_models.inputs import Input + +sys.path.append("src/") def test_addmarginals() -> None: -- GitLab