From c1532782e569f8e03bb61bba14a54a0fc16ae3ae Mon Sep 17 00:00:00 2001 From: David Coster Date: Sat, 30 Sep 2023 07:06:49 +0200 Subject: [PATCH 1/3] add options to suppress the calculation of large memory objects that might not be needed --- easyvvuq/analysis/pce_analysis.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/easyvvuq/analysis/pce_analysis.py b/easyvvuq/analysis/pce_analysis.py index cc26d661..579b44f7 100644 --- a/easyvvuq/analysis/pce_analysis.py +++ b/easyvvuq/analysis/pce_analysis.py @@ -182,7 +182,7 @@ def get_distribution(self, qoi): class PCEAnalysis(BaseAnalysisElement): - def __init__(self, sampler=None, qoi_cols=None, sampling=False): + def __init__(self, sampler=None, qoi_cols=None, sampling=False, noCorrelationMatrices=False, noOutputDistributions=False): """Analysis element for polynomial chaos expansion (PCE). Parameters @@ -211,6 +211,8 @@ def __init__(self, sampler=None, qoi_cols=None, sampling=False): self.sampling = sampling self.output_type = OutputType.SUMMARY self.sampler = sampler + self.noCorrelationMatrices = noCorrelationMatrices + self.noOutputDistributions = noOutputDistributions def element_name(self): """Name for this element for logging purposes. @@ -506,11 +508,15 @@ def build_surrogate_der(Y_hat, verbose=False): # Correlation matrix try: - warnings.warn(f"Skipping computation of cp.Corr", RuntimeWarning) if self.sampler._is_dependent: + warnings.warn(f"Skipping computation of cp.Corr", RuntimeWarning) results['correlation_matrices'][k] = None else: - results['correlation_matrices'][k] = cp.Corr(fit, self.sampler.distribution) + if not self.noCorrelationMatrices: + results['correlation_matrices'][k] = cp.Corr(fit, self.sampler.distribution) + else: + warnings.warn(f"Skipping computation of cp.Corr", RuntimeWarning) + results['correlation_matrices'][k] = None except Exception as e: print ('Error %s for %s when computing cp.Corr()'% (e.__class__.__name__, k)) results['correlation_matrices'][k] = None @@ -518,11 +524,15 @@ def build_surrogate_der(Y_hat, verbose=False): # Output distributions try: - warnings.warn(f"Skipping computation of cp.QoI_Dist", RuntimeWarning) if self.sampler._is_dependent: + warnings.warn(f"Skipping computation of cp.QoI_Dist", RuntimeWarning) results['output_distributions'][k] = None else: - results['output_distributions'][k] = cp.QoI_Dist( fit, self.sampler.distribution) + if not self.noOutputDistributions: + results['output_distributions'][k] = cp.QoI_Dist( fit, self.sampler.distribution) + else: + warnings.warn(f"Skipping computation of cp.QoI_Dist", RuntimeWarning) + results['output_distributions'][k] = None except Exception as e: print ('Error %s for %s when computing cp.QoI_Dist()'% (e.__class__.__name__, k)) # from traceback import print_exc From 62434d7bc7db7d206aeeb4c93ba107445c99cff9 Mon Sep 17 00:00:00 2001 From: David Coster Date: Sun, 1 Oct 2023 12:44:11 +0200 Subject: [PATCH 2/3] switch to CorrelationMatrices=True, OutputDistributions=True rather than noCorrelationMatrices=False, noOutputDistributions=False --- easyvvuq/analysis/pce_analysis.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/easyvvuq/analysis/pce_analysis.py b/easyvvuq/analysis/pce_analysis.py index 579b44f7..cea7e7e2 100644 --- a/easyvvuq/analysis/pce_analysis.py +++ b/easyvvuq/analysis/pce_analysis.py @@ -182,7 +182,7 @@ def get_distribution(self, qoi): class PCEAnalysis(BaseAnalysisElement): - def __init__(self, sampler=None, qoi_cols=None, sampling=False, noCorrelationMatrices=False, noOutputDistributions=False): + def __init__(self, sampler=None, qoi_cols=None, sampling=False, CorrelationMatrices=True, OutputDistributions=True): """Analysis element for polynomial chaos expansion (PCE). Parameters @@ -193,7 +193,13 @@ def __init__(self, sampler=None, qoi_cols=None, sampling=False, noCorrelationMat Column names for quantities of interest (for which analysis is performed). sampling : True if chaospy sampling method to be used for calculating - statitical quantities; otherwise [default] the pce coefficients are used + statistical quantities; otherwise [default] the pce coefficients are used + CorrelationMatrices : boolean + if False then disable the calculation of the Correlation Matrices, otherwise + [default] calculate them + OutputDistributions : boolean + if False then disable the calculation of the Output Distributions, otherwise + [default] calculate them """ if sampler is None: @@ -211,8 +217,8 @@ def __init__(self, sampler=None, qoi_cols=None, sampling=False, noCorrelationMat self.sampling = sampling self.output_type = OutputType.SUMMARY self.sampler = sampler - self.noCorrelationMatrices = noCorrelationMatrices - self.noOutputDistributions = noOutputDistributions + self.CorrelationMatrices = CorrelationMatrices + self.OutputDistributions = OutputDistributions def element_name(self): """Name for this element for logging purposes. @@ -512,7 +518,7 @@ def build_surrogate_der(Y_hat, verbose=False): warnings.warn(f"Skipping computation of cp.Corr", RuntimeWarning) results['correlation_matrices'][k] = None else: - if not self.noCorrelationMatrices: + if self.CorrelationMatrices: results['correlation_matrices'][k] = cp.Corr(fit, self.sampler.distribution) else: warnings.warn(f"Skipping computation of cp.Corr", RuntimeWarning) @@ -528,7 +534,7 @@ def build_surrogate_der(Y_hat, verbose=False): warnings.warn(f"Skipping computation of cp.QoI_Dist", RuntimeWarning) results['output_distributions'][k] = None else: - if not self.noOutputDistributions: + if self.OutputDistributions: results['output_distributions'][k] = cp.QoI_Dist( fit, self.sampler.distribution) else: warnings.warn(f"Skipping computation of cp.QoI_Dist", RuntimeWarning) From e64a3db47ee84b276d4ce83dcdc5597698639ed2 Mon Sep 17 00:00:00 2001 From: David Coster Date: Mon, 2 Oct 2023 19:34:40 +0200 Subject: [PATCH 3/3] attempt to fix the problem with readthedocs --- .readthedocs.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 00000000..5fc242ca --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,35 @@ +# Read the Docs configuration file for Sphinx projects +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.11" + # You can also specify other tool versions: + # nodejs: "20" + # rust: "1.70" + # golang: "1.20" + +# Build documentation in the "docs/" directory with Sphinx +sphinx: + configuration: docs/source/conf.py + # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs + # builder: "dirhtml" + # Fail on all warnings to avoid broken references + # fail_on_warning: true + +# Optionally build your docs in additional formats such as PDF and ePub +# formats: +# - pdf +# - epub + +# Optional but recommended, declare the Python requirements required +# to build your documentation +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +# python: +# install: +# - requirements: docs/requirements.txt \ No newline at end of file