Skip to content

Commit

Permalink
Fixes sphinx warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dimtsap committed May 2, 2023
1 parent d2f3722 commit 9e6a00b
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 40 deletions.
21 changes: 11 additions & 10 deletions docs/code/dimension_reduction/grassmann/plot_grassmann_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from UQpy.dimension_reduction.grassmann_manifold.projections.SVDProjection import SVDProjection
from UQpy.dimension_reduction import GrassmannOperations
from UQpy.utilities import GrassmannPoint
from UQpy.utilities.kernels import Kernel, ProjectionKernel
from UQpy.utilities.kernels import ProjectionKernel
import sys

# %% md
Expand Down Expand Up @@ -73,10 +73,10 @@
# %%
projection_kernel = ProjectionKernel()

projection_kernel.calculate_kernel_matrix(points=manifold_projection.u)
projection_kernel.calculate_kernel_matrix(x=manifold_projection.u, s=manifold_projection.u)
kernel_psi = projection_kernel.kernel_matrix

projection_kernel.calculate_kernel_matrix(points=manifold_projection.v)
projection_kernel.calculate_kernel_matrix(x=manifold_projection.v, s=manifold_projection.v)
kernel_phi = projection_kernel.kernel_matrix

fig, (ax1, ax2) = plt.subplots(1, 2)
Expand All @@ -92,9 +92,9 @@

# %%

projection_kernel.calculate_kernel_matrix(points=[manifold_projection.u[0],
manifold_projection.u[1],
manifold_projection.u[2]])
projection_kernel.\
calculate_kernel_matrix(x=[manifold_projection.u[0], manifold_projection.u[1], manifold_projection.u[2]],
s=[manifold_projection.u[0], manifold_projection.u[1], manifold_projection.u[2]])
kernel_01 = projection_kernel.kernel_matrix

fig = plt.figure()
Expand All @@ -111,17 +111,18 @@

class UserKernel(GrassmannianKernel):

def kernel_entry(self, xi: GrassmannPoint, xj: GrassmannPoint):
r = np.dot(xi.data.T, xj.data)
def element_wise_operation(self, xi_j) -> float:
xi, xj = xi_j
r = np.dot(xi.T, xj)
det = np.linalg.det(r)
return det * det


user_kernel = UserKernel()
user_kernel.calculate_kernel_matrix(points=manifold_projection.u)
user_kernel.calculate_kernel_matrix(x=manifold_projection.u, s=manifold_projection.u)
kernel_user_psi = user_kernel.kernel_matrix

user_kernel.calculate_kernel_matrix(points=manifold_projection.v)
user_kernel.calculate_kernel_matrix(x=manifold_projection.v, s=manifold_projection.v)
kernel_user_phi = user_kernel.kernel_matrix

fig, (ax1, ax2) = plt.subplots(1, 2)
Expand Down
3 changes: 2 additions & 1 deletion docs/code/surrogates/gpr/plot_gpr_custom2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
from UQpy.surrogates import GaussianProcessRegression, Matern
from UQpy.surrogates import GaussianProcessRegression

# %% md
#
# Create a distribution object.

# %%
from UQpy.utilities import Matern

marginals = [Uniform(loc=0., scale=1.), Uniform(loc=0., scale=1.)]

Expand Down
9 changes: 5 additions & 4 deletions docs/code/surrogates/gpr/plot_gpr_no_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@

# %%

import numpy as np
import matplotlib.pyplot as plt
import warnings

import matplotlib.pyplot as plt
import numpy as np

from UQpy.surrogates.gaussian_process.regression_models.LinearRegression import LinearRegression
from UQpy.utilities import RBF

warnings.filterwarnings('ignore')
from UQpy.utilities.MinimizeOptimizer import MinimizeOptimizer
from UQpy.utilities.FminCobyla import FminCobyla
from UQpy.surrogates import GaussianProcessRegression, NonNegative, RBF
from UQpy.surrogates import GaussianProcessRegression


# %% md
Expand Down
5 changes: 4 additions & 1 deletion docs/code/surrogates/gpr/plot_gpr_noisy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
import numpy as np
import matplotlib.pyplot as plt
import warnings

from UQpy.utilities import RBF

warnings.filterwarnings('ignore')
from UQpy.utilities.MinimizeOptimizer import MinimizeOptimizer
from UQpy.surrogates.gaussian_process.regression_models.LinearRegression import LinearRegression
from UQpy.surrogates import GaussianProcessRegression, RBF
from UQpy.surrogates import GaussianProcessRegression


# %% md
Expand Down
3 changes: 2 additions & 1 deletion docs/code/surrogates/gpr/plot_gpr_sine.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
from UQpy.distributions import Gamma
import numpy as np
import matplotlib.pyplot as plt
from UQpy.surrogates import GaussianProcessRegression, RBF
from UQpy.surrogates import GaussianProcessRegression

# %% md
#
# Create a distribution object.

# %%
from UQpy.utilities import RBF

marginals = [Gamma(a=2., loc=1., scale=3.)]

Expand Down
5 changes: 3 additions & 2 deletions docs/code/surrogates/pce/plot_pce_camel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
.. math:: f(x) = \Big(4-2.1x_1^2 + \frac{x_1^4}{3} \Big)x_1^2 + x_1x_2 + (-4 + 4x_2^2)x_2^2
**Description:** Dimensions: 2
**Input Domain:** This function is evaluated on the hypercube :math:`x_1 \in [-3, 3], x_2 \in [-2, 2]`.
**Global minimum:** :math:`f(x^*)=-1.0316,` at :math:`x^* = (0.0898, -0.7126)` and
:math:`(-0.0898, 0.7126)`.
**Global minimum:** :math:`f(x^*)=-1.0316,` at :math:`x^* = (0.0898, -0.7126)` and :math:`(-0.0898, 0.7126)`.
**Reference:** Molga, M., & Smutnicki, C. Test functions for optimization needs (2005). Retrieved June 2013, from http://www.zsd.ict.pwr.wroc.pl/files/docs/functions.pdf.
"""

# %% md
Expand Down
32 changes: 24 additions & 8 deletions docs/source/bibliography.bib
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,19 @@ @article{saltelli_2002
keywords = {Sensitivity analysis, Sensitivity measures, Sensitivity indices, Importance measures},
}

@article{PTMCMC1,
title = {Parallel Tempering: Theory, Applications, and New Perspectives},
author = {David J. Earl, Michael W. Deem},
year = {2005},
doi = {https://doi.org/10.48550/arXiv.physics/0508111}
}
@Article{PTMCMC1,
author ="Earl, David J. and Deem, Michael W.",
title ="Parallel tempering: Theory{,} applications{,} and new perspectives",
journal ="Phys. Chem. Chem. Phys.",
year ="2005",
volume ="7",
issue ="23",
pages ="3910-3916",
publisher ="The Royal Society of Chemistry",
doi ="10.1039/B509983H",
url ="http://dx.doi.org/10.1039/B509983H",
abstract ="We review the history of the parallel tempering simulation method. From its origins in data analysis{,} the parallel tempering method has become a standard workhorse of physicochemical simulations. We discuss the theory behind the method and its various generalizations. We mention a selected set of the many applications that have become possible with the introduction of parallel tempering{,} and we suggest several promising avenues for future research."}


@inproceedings{PTMCMC2,
title = {Using Thermodynamic Integration to Calculate the Posterior Probability in Bayesian Model Selection Problems},
Expand All @@ -844,13 +851,22 @@ @inproceedings{PTMCMC2
author = {Paul M. Goggans and Ying Chi}
}


@article{STMCMC_ChingChen,
author = {Jianye Ching and Yi-Chu Chen },
title = {Transitional Markov Chain Monte Carlo Method for Bayesian Model Updating, Model Class Selection, and Model Averaging},
author = {Jianye Ching, Yi-Chu Chen},
journal = {Journal of Engineering Mechanics},
volume = {133},
number = {7},
pages = {816-832},
year = {2007},
doi = {https://doi.org/10.1061/(ASCE)0733-9399(2007)133:7(816)}
doi = {10.1061/(ASCE)0733-9399(2007)133:7(816)},
URL = {https://ascelibrary.org/doi/abs/10.1061/%28ASCE%290733-9399%282007%29133%3A7%28816%29},
eprint = {https://ascelibrary.org/doi/pdf/10.1061/%28ASCE%290733-9399%282007%29133%3A7%28816%29}
}



@article{Kle2D,
title = {Simulation of multi-dimensional random fields by Karhunen–Loève expansion},
journal = {Computer Methods in Applied Mechanics and Engineering},
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
language = None
language = "en"
pygments_style = None

html_theme = "sphinx_rtd_theme"
Expand Down
2 changes: 1 addition & 1 deletion docs/source/stochastic_process/karhunen_loeve_1d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Examples

.. toctree::

Karhunen Loeve Examples <../auto_examples/stochastic_processes/karhunen_loeve/index>
Karhunen Loeve Examples <../auto_examples/stochastic_processes/karhunen_loeve_1d/index>
4 changes: 2 additions & 2 deletions docs/source/stochastic_process/karhunen_loeve_2d.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Karhunen Loève Expansion for Multi-Dimensional Fields
----------------------------
-----------------------------------------------------

The Karhunen Loève Expansion expands the stochastic field as follows:

Expand All @@ -9,7 +9,7 @@ where :math:`\eta_{nk}(\theta)` are uncorrelated standardized normal random vari
at :cite:`Kle2D`

KarhunenLoeve2D Class
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^

The :class:`.KarhunenLoeve2D` class is imported using the following command:

Expand Down
9 changes: 3 additions & 6 deletions docs/source/surrogates/gpr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,13 @@ User-Defined Kernel
""""""""""""""""""""""""""""

Adding a new kernel to the :class:`.GaussianProcessRegression` class is straightforward. This is done by creating a new class
that extends the :class:`UQpy.surrogates.gaussian_process.kernels.baseclass.Kernel` abstract base class.
that extends the :class:`.Kernel` abstract base class.
This new class must have a method ``c(self, x, s, params)`` that takes as input the new points, training points and hyperparameters.
Notice that the input ``params`` include lengthscales and process standard deviation, not noise standard deviation (even for noisy data).

The :class:`UQpy.surrogates.gaussian_process.kernels.baseclass.Kernel` class is imported using the following command:
The :class:`.Kernel` class is imported using the following command:

>>> from UQpy.surrogates.gaussian_process.kernels.baseclass.Kernel import Kernel

.. autoclass:: UQpy.surrogates.gaussian_process.Kernel
:members:
>>> from UQpy.utilities.kernels.baseclass.Kernel import Kernel

The method should return covariance matrix, i.e. a 2-D array with first dimension
being the number of new points and second dimension being the number of training points.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/utilities/kernels/euclidean_kernels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Methods
~~~~~~~~~

.. autoclass:: UQpy.utilities.kernels.GaussianKernel
:members: kernel_entry, optimize_parameters
:members: optimize_parameters

Attributes
~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/source/utilities/kernels/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The :class:`UQpy.utilities.kernels.baseclass.Kernel` class is imported using the
>>> from UQpy.utilities.kernels.baseclass.Kernel import Kernel

.. autoclass:: UQpy.utilities.kernels.baseclass.Kernel
:members: kernel_entry, optimize_parameters, calculate_kernel_matrix
:members: calculate_kernel_matrix

Types of Kernels
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, pdf_intermediate=None, log_pdf_intermediate=None, args_pdf_in
least two inputs :code:`x` (ndarray, point(s) at which to evaluate the function), and :code:`temper_param` (float,
tempering parameter). Eit her `pdf_intermediate` or `log_pdf_intermediate` must be provided
(`log_pdf_intermediate` is preferred). Within the code, the `log_pdf_intermediate` is evaluated as:
:code:`log_pdf_intermediate(x, temper_param, *args_pdf_intermediate)`
:code:`log_pdf_intermediate(x, temper_param, *args_pdf_intermediate)`
where `args_pdf_intermediate` are additional positional arguments that are provided to the class via its
`args_pdf_intermediate` input
:param log_pdf_intermediate: see `pdf_intermediate`
Expand Down
1 change: 1 addition & 0 deletions src/UQpy/utilities/kernels/baseclass/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from UQpy.utilities.kernels.baseclass.EuclideanKernel import EuclideanKernel
from UQpy.utilities.kernels.baseclass.GrassmannianKernel import GrassmannianKernel
from UQpy.utilities.kernels.baseclass.Kernel import Kernel

0 comments on commit 9e6a00b

Please sign in to comment.