Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Development' into feature/CI
Browse files Browse the repository at this point in the history
# Conflicts:
#	setup.py
  • Loading branch information
dgiovanis committed Feb 18, 2021
2 parents 76863be + 3a4ddb1 commit b3eefe7
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 140 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Uncertainty Quantification with python (UQpy)

:Authors: Michael D. Shields, Dimitris G. Giovanis, Audrey Olivier, Aakash Bangalore Satish, Mohit Singh Chauhan, Lohit Vandanapu, Ketson RM dos Santos, Katiana Kontolati
:Contact: [email protected]
:Version: 3.0.3
:Version: 3.0.4


Description
Expand Down Expand Up @@ -85,7 +85,7 @@ For assistance with the UQpy software package, please raise an issue on the Gith

.. image:: https://img.shields.io/pypi/dm/UQpy?style=plastic :alt: PyPI - Downloads
.. image:: https://img.shields.io/conda/dn/conda-forge/UQpy?style=plastic :alt: Conda
.. image:: https://img.shields.io/github/downloads/SURGroup/UQpy/v3.0.1/total?style=plastic :alt: GitHub Releases (by Release)
.. image:: https://img.shields.io/github/downloads/SURGroup/UQpy/V3.0.4/total?style=plastic :alt: GitHub Releases (by Release)

.. image:: https://img.shields.io/pypi/v/UQpy?style=plastic :alt: PyPI
.. image:: https://img.shields.io/conda/v/conda-forge/UQpy?style=plastic :alt: Conda
Expand Down
2 changes: 1 addition & 1 deletion docs/source/runmodel_doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ To execute ``RunModel``, the working directory must contain the necessary files
.. image:: _static/Runmodel_directory_1.png
:width: 300

To avoid cluttering the working directory with outputs, ``RunModel`` creates a directory for each execution of the model and saves the output generated during the model execution within the corresponding directory. ``RunModel`` generates the directory name for the sample as `run_n_timestamp`, where `n` is the python index of the run and `timestamp` corresponds to the time at the beginning of the first simulation of the parallel job. This is illustrated in the figure below.
To avoid cluttering the working directory with outputs, ``RunModel`` creates a directory for each execution of the model and saves the output generated during the model execution within the corresponding directory. ``RunModel`` generates the directory name for the sample as `run_n`, where `n` is the python index of the run and `timestamp` corresponds to the time at the beginning of the first simulation of the parallel job. This is illustrated in the figure below.

.. image:: _static/Runmodel_directory_2.png
:width: 300
Expand Down
2 changes: 1 addition & 1 deletion example/RunModel/Abaqus_Example/abaqus_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
print('Example: Created the model object.')

# Towards defining the sampling scheme
# The fire load density is assumed to be uniformly distributed between 50 MJ/number_of_variables^2 and 450 MJ/number_of_variables^2.
# The fire load density is assumed to be uniformly distributed between 50 MJ/m^2 and 450 MJ/m^2.
# The yield strength is assumed to be normally distributed, with the parameters
# being: mean = 250 MPa and coefficient of variation of 7%.

Expand Down
4 changes: 2 additions & 2 deletions example/RunModel/Abaqus_Example/extract_abaqus_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def extract_disp_temp_output(index):
os.remove(os.path.join(dir_name, item))

# Compute the maximum allowable displacement
length_of_beam = 1 # in number_of_variables
depth_of_beam = 0.035 # in number_of_variables
length_of_beam = 1 # in m
depth_of_beam = 0.035 # in m
max_allowable_disp = length_of_beam ** 2 / (400 * depth_of_beam)

# Obtain the maximum midpoint displacement
Expand Down
6 changes: 3 additions & 3 deletions example/RunModel/Matlab_Example/matlab_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@


def matlab(index):
command1 = "cp ./InputFiles/dummy_model_" + str(index) + ".number_of_variables ."
command1 = "cp ./InputFiles/dummy_model_" + str(index) + ".m ."
command2 = "/Applications/MATLAB_R2018a.app/bin/matlab " \
"-nosplash -nojvm -nodisplay -nodesktop -r 'run dummy_model_" + str(index) + ".number_of_variables; exit'"
"-nosplash -nojvm -nodisplay -nodesktop -r 'run dummy_model_" + str(index) + ".m; exit'"
command3 = "mv ./OutputFiles/oupt.out ./OutputFiles/oupt_" + str(index) + ".out"
command4 = "rm dummy_model_" + str(index) + ".number_of_variables"
command4 = "rm dummy_model_" + str(index) + ".m"
os.system(command1)
os.system(command2)
os.system(command3)
Expand Down
6 changes: 3 additions & 3 deletions example/RunModel/Matlab_Example/matlab_model_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@


def matlab(index):
command1 = "cp ./InputFiles/prod_determinant_" + str(index) + ".number_of_variables ."
command1 = "cp ./InputFiles/prod_determinant_" + str(index) + ".m ."
# The user will need to modify command2 to point to the Matlab application on their system.
command2 = "/Applications/MATLAB_R2018a.app/bin/matlab " \
"-nosplash -nojvm -nodisplay -nodesktop -r 'run prod_determinant_" + str(index) + ".number_of_variables; exit'"
"-nosplash -nojvm -nodisplay -nodesktop -r 'run prod_determinant_" + str(index) + ".m; exit'"
command3 = "mv ./OutputFiles/oupt.out ./OutputFiles/oupt_" + str(index) + ".out"
command4 = "rm prod_determinant_" + str(index) + ".number_of_variables"
command4 = "rm prod_determinant_" + str(index) + ".m"
os.system(command1)
os.system(command2)
os.system(command3)
Expand Down
6 changes: 3 additions & 3 deletions example/RunModel/Matlab_Example/matlab_model_det_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@


def matlab(index):
command1 = "cp ./InputFiles/prod_determinant_index_" + str(index) + ".number_of_variables ."
command1 = "cp ./InputFiles/prod_determinant_index_" + str(index) + ".m ."
# The user will need to modify command2 to point to the Matlab application on their system.
command2 = "/Applications/MATLAB_R2018a.app/bin/matlab " \
"-nosplash -nojvm -nodisplay -nodesktop -r 'run prod_determinant_index_" + str(index) + ".number_of_variables; exit'"
"-nosplash -nojvm -nodisplay -nodesktop -r 'run prod_determinant_index_" + str(index) + ".m; exit'"
command3 = "mv ./OutputFiles/oupt.out ./OutputFiles/oupt_" + str(index) + ".out"
command4 = "rm prod_determinant_index_" + str(index) + ".number_of_variables"
command4 = "rm prod_determinant_index_" + str(index) + ".m"
os.system(command1)
os.system(command2)
os.system(command3)
Expand Down
6 changes: 3 additions & 3 deletions example/RunModel/Matlab_Example/matlab_model_det_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@


def matlab(index):
command1 = "cp ./InputFiles/prod_determinant_partial_" + str(index) + ".number_of_variables ."
command1 = "cp ./InputFiles/prod_determinant_partial_" + str(index) + ".m ."
# The user will need to modify command2 to point to the Matlab application on their system.
command2 = "/Applications/MATLAB_R2018a.app/bin/matlab " \
"-nosplash -nojvm -nodisplay -nodesktop -r 'run prod_determinant_partial_" + str(index) + ".number_of_variables; exit'"
"-nosplash -nojvm -nodisplay -nodesktop -r 'run prod_determinant_partial_" + str(index) + ".m; exit'"
command3 = "mv ./OutputFiles/oupt.out ./OutputFiles/oupt_" + str(index) + ".out"
command4 = "rm prod_determinant_partial_" + str(index) + ".number_of_variables"
command4 = "rm prod_determinant_partial_" + str(index) + ".m"
os.system(command1)
os.system(command2)
os.system(command3)
Expand Down
6 changes: 3 additions & 3 deletions example/RunModel/Matlab_Example/matlab_model_sum_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@


def matlab(index):
command1 = "cp ./InputFiles/sum_scalar_" + str(index) + ".number_of_variables ."
command1 = "cp ./InputFiles/sum_scalar_" + str(index) + ".m ."
# The user will need to modify command2 to point to the Matlab application on their system.
command2 = "/Applications/MATLAB_R2018a.app/bin/matlab " \
"-nosplash -nojvm -nodisplay -nodesktop -r 'run sum_scalar_" + str(index) + ".number_of_variables; exit'"
"-nosplash -nojvm -nodisplay -nodesktop -r 'run sum_scalar_" + str(index) + ".m; exit'"
command3 = "mv ./OutputFiles/oupt.out ./OutputFiles/oupt_" + str(index) + ".out"
command4 = "rm sum_scalar_" + str(index) + ".number_of_variables"
command4 = "rm sum_scalar_" + str(index) + ".m"
os.system(command1)
os.system(command2)
os.system(command3)
Expand Down
6 changes: 3 additions & 3 deletions example/RunModel/Matlab_Example/matlab_model_sum_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@


def matlab(index):
command1 = "cp ./InputFiles/sum_vector_" + str(index) + ".number_of_variables ."
command1 = "cp ./InputFiles/sum_vector_" + str(index) + ".m ."
# The user will need to modify command2 to point to the Matlab application on their system.
command2 = "/Applications/MATLAB_R2018a.app/bin/matlab " \
"-nosplash -nojvm -nodisplay -nodesktop -r 'run sum_vector_" + str(index) + ".number_of_variables; exit'"
"-nosplash -nojvm -nodisplay -nodesktop -r 'run sum_vector_" + str(index) + ".m; exit'"
command3 = "mv ./OutputFiles/oupt.out ./OutputFiles/oupt_" + str(index) + ".out"
command4 = "rm sum_vector_" + str(index) + ".number_of_variables"
command4 = "rm sum_vector_" + str(index) + ".m"
os.system(command1)
os.system(command2)
os.system(command3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@


def matlab(index):
command1 = "cp ./InputFiles/sum_vector_indexed_" + str(index) + ".number_of_variables ."
command1 = "cp ./InputFiles/sum_vector_indexed_" + str(index) + ".m ."
# The user will need to modify command2 to point to the Matlab application on their system.
command2 = "/Applications/MATLAB_R2018a.app/bin/matlab " \
"-nosplash -nojvm -nodisplay -nodesktop -r 'run sum_vector_indexed_" + str(index) + ".number_of_variables; exit'"
"-nosplash -nojvm -nodisplay -nodesktop -r 'run sum_vector_indexed_" + str(index) + ".m; exit'"
command3 = "mv ./OutputFiles/oupt.out ./OutputFiles/oupt_" + str(index) + ".out"
command4 = "rm sum_vector_indexed_" + str(index) + ".number_of_variables"
command4 = "rm sum_vector_indexed_" + str(index) + ".m"
os.system(command1)
os.system(command2)
os.system(command3)
Expand Down
57 changes: 27 additions & 30 deletions example/StochasticProcess/BSRM_nd.ipynb

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#!/usr/bin/env python
import sys
version = sys.argv[1]
del sys.argv[1]
from setuptools import setup, find_packages

setup(
name='UQpy',
version=version,
url='https://github.com/SURGroup/UQpy',
description="UQpy is a general purpose toolbox for Uncertainty Quantification",
author="Michael D. Shields, Dimitris G. Giovanis, Audrey Olivier, Aakash Bangalore-Satish, Mohit Chauhan, "
"Lohit Vandanapu, Ketson R.M. dos Santos",
author_email="[email protected]",
license='MIT',
platforms=["OSX", "Windows", "Linux"],
packages=find_packages("src"),
package_dir={"": "src"},
package_data={"": ["*.pdf"]},
install_requires=[
"numpy", "scipy", "matplotlib", "scikit-learn", 'fire'
],
classifiers=[
'Programming Language :: Python :: 3',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Mathematics',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
],
)
#!/usr/bin/env python
import sys
version = sys.argv[1]
del sys.argv[1]
from setuptools import setup, find_packages

setup(
name='UQpy',
version=version,
url='https://github.com/SURGroup/UQpy',
description="UQpy is a general purpose toolbox for Uncertainty Quantification",
author="Michael D. Shields, Dimitris G. Giovanis, Audrey Olivier, Aakash Bangalore-Satish, Mohit Chauhan, "
"Lohit Vandanapu, Ketson R.M. dos Santos",
author_email="[email protected]",
license='MIT',
platforms=["OSX", "Windows", "Linux"],
packages=find_packages("src"),
package_dir={"": "src"},
package_data={"": ["*.pdf"]},
install_requires=[
"numpy", "scipy", "matplotlib", "scikit-learn", 'fire'
],
classifiers=[
'Programming Language :: Python :: 3',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Mathematics',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
],
)
35 changes: 17 additions & 18 deletions src/UQpy/Distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class Distribution:
Generated iid samples, `ndarray` of shape `(npoints, dimension)`.
**moments** *(moments2return='mvsk')*
Computes the mean 'number_of_variables', variance/covariance ('v'), skewness ('s') and/or kurtosis ('k') of the distribution.
Computes the mean 'm', variance/covariance ('v'), skewness ('s') and/or kurtosis ('k') of the distribution.
For a univariate distribution, mean, variance, skewness and kurtosis are returned. For a multivariate
distribution, the mean vector, covariance and vectors of marginal skewness and marginal kurtosis are returned.
Expand Down Expand Up @@ -816,16 +816,16 @@ class Binomial(DistributionDiscrete1D):
"""
Binomial distribution having probability mass function:
.. math:: f(x) = {number_of_dimensions \choose x} p^x(1-p)^{number_of_dimensions-x}
.. math:: f(x) = {n \choose x} p^x(1-p)^{n-x}
for :math:`x\inumber_of_dimensions\{0, 1, 2, ..., number_of_dimensions\}`.
for :math:`x\in\{0, 1, 2, ..., n\}`.
In this standard form `(loc=0)`. Use `loc` to shift the distribution. Specifically, this is equivalent to computing
:math:`f(y)` where :math:`y=x-loc`.
**Inputs:**
* **number_of_dimensions** (`int`):
* **n** (`int`):
number of trials, integer >= 0
* **p** (`float`):
success probability for each trial, real number in [0, 1]
Expand All @@ -837,7 +837,7 @@ class Binomial(DistributionDiscrete1D):
* ``cdf``, ``pmf``, ``log_pmf``, ``icdf``, ``rvs, moments``.
"""
def __init__(self, n, p, loc=0.):
super().__init__(n=n, p=p, loc=loc, order_params=('number_of_dimensions', 'p', 'loc'))
super().__init__(n=n, p=p, loc=loc, order_params=('n', 'p', 'loc'))
self._construct_from_scipy(scipy_name=stats.binom)


Expand Down Expand Up @@ -947,27 +947,27 @@ def fit(self, x):
return {'mean': mle_mu, 'cov': mle_cov}

def moments(self, moments2return='mv'):
if moments2return == 'number_of_variables':
if moments2return == 'm':
return self.get_params()['mean']
elif moments2return == 'v':
return self.get_params()['cov']
elif moments2return == 'mv':
return self.get_params()['mean'], self.get_params()['cov']
else:
raise ValueError('UQpy: moments2return must be "number_of_variables", "v" or "mv".')
raise ValueError('UQpy: moments2return must be "m", "v" or "mv".')


class Multinomial(DistributionND):
"""
Multinomial distribution having probability mass function
.. math:: f(x) = \dfrac{number_of_dimensions!}{x_1!\dots x_k!}p_1^{x_1}\dots p_k^{x_k}
.. math:: f(x) = \dfrac{n!}{x_1!\dots x_k!}p_1^{x_1}\dots p_k^{x_k}
for :math:`x=\{x_1,\dots,x_k\}` where each :math:`x_i` is a non-negative integer and :math:`\sum_i x_i = number_of_dimensions`.
for :math:`x=\{x_1,\dots,x_k\}` where each :math:`x_i` is a non-negative integer and :math:`\sum_i x_i = n`.
**Inputs:**
* **number_of_dimensions** (`int`):
* **n** (`int`):
number of trials
* **p** (`array_like`):
probability of a trial falling into each category; should sum to 1
Expand All @@ -994,24 +994,24 @@ def rvs(self, nsamples=1, random_state=None):
size=nsamples, random_state=random_state, **self.params).reshape((nsamples, -1))

def moments(self, moments2return='mv'):
if moments2return == 'number_of_variables':
mean = self.get_params()['number_of_dimensions'] * np.array(self.get_params()['p'])
if moments2return == 'm':
mean = self.get_params()['n'] * np.array(self.get_params()['p'])
return mean
elif moments2return == 'v':
n, p = self.get_params()['number_of_dimensions'], np.array(self.get_params()['p'])
n, p = self.get_params()['n'], np.array(self.get_params()['p'])
d = len(p)
cov = - n * np.tile(p[np.newaxis, :], [d, 1]) * np.tile(p[:, np.newaxis], [1, d])
np.fill_diagonal(cov, n * p * (1. - p))
return cov
elif moments2return == 'mv':
n, p = self.get_params()['number_of_dimensions'], np.array(self.get_params()['p'])
n, p = self.get_params()['n'], np.array(self.get_params()['p'])
d = len(p)
cov = - n * np.tile(p[np.newaxis, :], [d, 1]) * np.tile(p[:, np.newaxis], [1, d])
np.fill_diagonal(cov, n * p * (1. - p))
mean = n * p
return mean, cov
else:
raise ValueError('UQpy: moments2return must be "number_of_variables", "v" or "mv".')
raise ValueError('UQpy: moments2return must be "m", "v" or "mv".')


class JointInd(DistributionND):
Expand Down Expand Up @@ -1514,8 +1514,7 @@ class Frank(Copula):
**Input:**
* **theta** (`float`):
Parameter of the copula, real number in correlation_function\{0}.
* **theta** (`float`):R\{0}.
This copula possesses the following methods:
Expand All @@ -1526,7 +1525,7 @@ class Frank(Copula):
def __init__(self, theta):
# Check the input copula_params
if theta is not None and ((not isinstance(theta, (float, int))) or (theta == 0.)):
raise ValueError('Input theta should be a float in correlation_function\{0}.')
raise ValueError('Input theta should be a float in R\{0}.')
super().__init__(theta=theta)

def evaluate_cdf(self, unif):
Expand Down
Loading

0 comments on commit b3eefe7

Please sign in to comment.