Skip to content

Commit

Permalink
Restructure: take wrappers and I/O from partialwrap, take function di…
Browse files Browse the repository at this point in the history
…rectory from jams.
  • Loading branch information
mcuntz committed Jun 16, 2020
1 parent 4112f11 commit 3bd7bcf
Show file tree
Hide file tree
Showing 48 changed files with 3,529 additions and 3,477 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

All notable changes after its initial development up to January 2020 (v0.2) are documented in this file.

### v1.3 (??? 2020)
### v2.0 (Jun 2020)
- Use package partialwrap in docstrings and documentation.
- Remove utils directory: tee.py is now directly in pyeee directory.
- Sync const and functions of JAMS package.
- Small refinements of documentation.
- Generalise setup structure.
- Generalise structure of setup.py.
- Use python3 for *nix and python for Windows on TravisCI.

### v1.2 (Apr 2020)
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ with a clear description of the problem and if possible with a
- please add the version number to the issue:

```python
import pyeee
print(pyeee.__version__)
import pyeee
print(pyeee.__version__)
```

## Do you have suggestions for new features?
Expand Down
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# pyeee - Parameter screening of computational models
<!-- pandoc -f gfm -o README.html -t html README.md -->

A Python library for parameter screening of computational models
using Morris' method of Elementary Effects or its extension of
Efficient/Sequential Elementary Effects by Cuntz, Mai et al. (Water
Res Research, 2015).
A Python library for parameter screening of computational models using Morris'
method of Elementary Effects or its extension of Efficient/Sequential Elementary
Effects by Cuntz, Mai et al. (Water Res Research, 2015).

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3620909.svg)](https://doi.org/10.5281/zenodo.3620909)
<!-- [![DOI](https://zenodo.org/badge/233405522.svg)](https://zenodo.org/badge/latestdoi/233405522) -->
Expand All @@ -17,19 +16,23 @@ Res Research, 2015).

## About pyeee

*pyeee* is a Python library for performing parameter screening of
computational models. It uses Morris' method of Elementary Effects
and also its extension of Efficient or Sequential Elementary Effects published of
*pyeee* is a Python library for performing parameter screening of computational
models. It uses Morris' method of Elementary Effects and also its extension of
Efficient or Sequential Elementary Effects published of

Cuntz, Mai *et al.* (2015)
Computationally inexpensive identification of noninformative model
parameters by sequential screening
*Water Resources Research* 51, 6417-6441,
doi:[10.1002/2015WR016907](http://doi.org/10.1002/2015WR016907).

*pyeee* can be used with Python functions but wrappers are provided
to use it with executables as well. Function evaluation can be
distributed with Python's multiprocessing or via MPI.
The package uses several functions of the JAMS Python package
https://github.com/mcuntz/jams_python
The JAMS package and *hesseflux* are synchronised irregularly.

*pyeee* can be used with Python functions but also with external programs, using
for example [partialwrap](http://partialwrap.readthedocs.org/en/latest).
Function evaluation can be distributed with Python's multiprocessing or via MPI.


## Documentation
Expand Down Expand Up @@ -78,8 +81,8 @@ which gives the Elementary Effects ($\mu*$):
# gives: 173.1 0.6 61.7
```

Sequential Elementary Effects distinguish between informative and
uninformative parameters using several times Morris' Elementary Effects:
Sequential Elementary Effects distinguish between informative and uninformative
parameters using several times Morris' Elementary Effects:

```python
# screen
Expand All @@ -88,8 +91,8 @@ uninformative parameters using several times Morris' Elementary Effects:
out = eee(ishigami1, lb, ub, ntfirst=10)
```

which returns a logical ndarray with True for the informative
parameters and False for the uninformative parameters:
which returns a logical ndarray with True for the informative parameters and
False for the uninformative parameters:

```python
print(out)
Expand All @@ -98,8 +101,8 @@ parameters and False for the uninformative parameters:

### Python function with extra parameters

The function for pyeee must be of the form `func(x)`. Use Python's
partial from the functools module to pass other function parameters.
The function for pyeee must be of the form `func(x)`. Use Python's partial from
the functools module to pass other function parameters.

For example pass the parameters $a$ and $b$ to the Ishigami-Homma function.

Expand Down Expand Up @@ -130,15 +133,16 @@ For example pass the parameters $a$ and $b$ to the Ishigami-Homma function.
out = ee(func, lb, ub, 10)
```

`partial` passes `a` and `b` to the
function `call_func_ab` already during definition so that *pyeee*
can then simply call it as `func(x)`, so that `x` is passed to
`call_func_ab` as well.
Figuratively speaking, `partial` passes `a` and `b` to the function
`call_func_ab` already during definition so that *pyeee* can then simply call it
as `func(x)`, so that `x` is passed to `call_func_ab` as well.


### Function wrappers

*pyeee* provides wrappers to use with partial.
We recommend to use the package
[partialwrap](http://partialwrap.readthedocs.org/en/latest), which provides
wrappers to use with partial.

```python
from pyeee.utils import func_wrapper
Expand All @@ -151,8 +155,9 @@ can then simply call it as `func(x)`, so that `x` is passed to
```

There are wrappers to use with Python functions with or without
masking parameters, as well as wrappers for external executables. See the
documentation for details.
masking parameters, as well as wrappers for external programs.

See the documentation for details:

http://pyeee.readthedocs.org/en/latest/

Expand Down
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# required for readthedocs.org
numpydoc
numpy
scipy
schwimmbad
partialwrap
20 changes: 10 additions & 10 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ def setup(app):

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"Python 3.9": ("https://docs.python.org/3.9", None),
"Python 3.6": ("https://docs.python.org/3.6", None),
"Python": ("https://docs.python.org/", None),
"NumPy": ("http://docs.scipy.org/doc/numpy/", None),
"SciPy": ("http://docs.scipy.org/doc/scipy/reference/", None),
"matplotlib": ("http://matplotlib.org/", None),
"Sphinx": ("https://sphinx.readthedocs.io/en/latest/", None),
"schwimmbad": ("https://schwimmbad.readthedocs.io/en/latest/", None),
"mpi4py": ("https://mpi4py.readthedocs.io/en/latest/", None),
"emcee": ("https://emcee.readthedocs.io/en/latest/", None),
"Python": ("https://docs.python.org/3/", None),
"NumPy": ("https://numpy.org/doc/stable/", None),
"SciPy": ("https://docs.scipy.org/doc/scipy/reference/", None),
"matplotlib": ("https://matplotlib.org/", None),
"cython": ("https://cython.readthedocs.io/en/latest/", None),
"Sphinx": ("https://www.sphinx-doc.org/en/master/", None),
"schwimmbad": ("https://schwimmbad.readthedocs.io/en/latest/", None),
"mpi4py": ("https://mpi4py.readthedocs.io/en/latest/", None),
"emcee": ("https://emcee.readthedocs.io/en/latest/", None),
"partialwrap": ("https://partialwrap.readthedocs.io/en/latest/", None),
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyeee.utils
pyeee.const.const
=================

.. automodule:: pyeee.functions.utils
.. automodule:: pyeee.const.const
:members:
:undoc-members:
:inherited-members:
Expand Down
6 changes: 3 additions & 3 deletions docs/source/utils.std_io.rst → docs/source/const.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyeee.std_io
=======================
pyeee.const
===========

.. automodule:: pyeee.utils.std_io
.. automodule:: pyeee.const
:members:
:undoc-members:
:inherited-members:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/eee.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pyeee.eee
=================
=========

.. automodule:: pyeee.eee
:members:
Expand Down
12 changes: 12 additions & 0 deletions docs/source/functions.fit_functions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pyeee.functions.fit_functions
=============================

.. automodule:: pyeee.functions.fit_functions
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

.. raw:: latex

\clearpage
4 changes: 2 additions & 2 deletions docs/source/functions.general_functions.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pyeee.general_functions
=======================
pyeee.functions.general_functions
=================================

.. automodule:: pyeee.functions.general_functions
:members:
Expand Down
12 changes: 12 additions & 0 deletions docs/source/functions.logistic_function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pyeee.functions.logistic_function
=================================

.. automodule:: pyeee.functions.logistic_function
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

.. raw:: latex

\clearpage
12 changes: 12 additions & 0 deletions docs/source/functions.opti_test_functions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pyeee.functions.opti_test_functions
===================================

.. automodule:: pyeee.functions.opti_test_functions
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

.. raw:: latex

\clearpage
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyeee.function_wrapper
=======================
pyeee.functions
===============

.. automodule:: pyeee.utils.function_wrapper
.. automodule:: pyeee.functions
:members:
:undoc-members:
:inherited-members:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/functions.sa_test_functions.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pyeee.sa_test_functions
=======================
pyeee.functions.sa_test_functions
=================================

.. automodule:: pyeee.functions.sa_test_functions
:members:
Expand Down
55 changes: 30 additions & 25 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Quickstart
==========

``pyeee``: A Python library for parameter screening of computational models
using Morris' method of Elementary Effects or its extension of
Efficient or Sequential Elementary Effects by Cuntz, Mai et al. (Water Res Research, 2015).
``pyeee``: A Python library for parameter screening of computational models using Morris' method of
Elementary Effects or its extension of Efficient or Sequential Elementary Effects by Cuntz, Mai et
al. (Water Res Research, 2015).

.. toctree::
:maxdepth: 3
Expand All @@ -14,19 +14,25 @@ Efficient or Sequential Elementary Effects by Cuntz, Mai et al. (Water Res Resea
About
============

``pyeee`` is a Python library for performing parameter screening of
computational models. It uses Morris' method of Elementary Effects
and also its extension of Efficient or Sequential Elementary Effects published by:
``pyeee`` is a Python library for performing parameter screening of computational models. It uses
Morris' method of Elementary Effects and also its extension of Efficient or Sequential Elementary
Effects published by:

Cuntz M, Mai J *et al.* (2015)
Computationally inexpensive identification of noninformative model
parameters by sequential screening
*Water Resources Research* 51, 6417-6441,
doi:`10.1002/2015WR016907 <http://doi.org/10.1002/2015WR016907>`_.

``pyeee`` can be used with Python functions but wrappers are provided
to use it with external executables as well. Function evaluation can be
distributed with Python's multiprocessing or via MPI.
``pyeee`` can be used with Python functions and external programs, using for example the package
:mod:`partialwrap`. Function evaluation can be distributed with Python's multiprocessing or via
MPI.

The package uses several functions of the JAMS Python package

https://github.com/mcuntz/jams_python

The JAMS package and hesseflux are synchronised irregularly.

The complete documentation for ``pyeee`` is available from Read The Docs.

Expand All @@ -49,8 +55,8 @@ Taking :math:`a = b = 1` gives:
def ishigami1(x):
return np.sin(x[0]) + np.sin(x[1])**2 + x[2]**4 * np.sin(x[0])
The three parameters :math:`x_0, x_1, x_2` follow uniform
distributions between :math:`-\pi` and :math:`+\pi`.
The three parameters :math:`x_0, x_1, x_2` follow uniform distributions between :math:`-\pi` and
:math:`+\pi`.

Morris' Elementary Effects can then be calculated like:

Expand All @@ -75,8 +81,8 @@ which gives the Elementary Effects (:math:`\mu*`):
print("{:.1f} {:.1f} {:.1f}".format(*out[:,0]))
# gives: 173.1 0.6 61.7
Sequential Elementary Effects distinguish between informative and
uninformative parameters using several times Morris' Elementary Effects:
Sequential Elementary Effects distinguish between informative and uninformative parameters using
several times Morris' Elementary Effects:

.. code-block:: python
Expand All @@ -85,8 +91,8 @@ uninformative parameters using several times Morris' Elementary Effects:
np.random.seed(seed=1021) # for reproducibility of examples
out = eee(ishigami1, lb, ub)
which returns a logical ndarray with True for the informative
parameters and False for the uninformative parameters:
which returns a logical ndarray with True for the informative parameters and False for the
uninformative parameters:

.. code-block:: python
Expand All @@ -97,8 +103,8 @@ parameters and False for the uninformative parameters:
Python function with extra parameters
-------------------------------------

The function for ``pyeee`` must be of the form `func(x)`. Use Python's
:func:`functools.partial` from the :mod:`functools` module to pass other function parameters.
The function for ``pyeee`` must be of the form `func(x)`. Use Python's :func:`functools.partial`
from the :mod:`functools` module to pass other function parameters.

For example pass the parameters :math:`a` and :math:`b` to the Ishigami-Homma function:

Expand Down Expand Up @@ -127,30 +133,29 @@ For example pass the parameters :math:`a` and :math:`b` to the Ishigami-Homma fu
np.random.seed(seed=1021) # for reproducibility of examples
out = ee(func, lb, ub, 10)
`partial` passes :math:`a` and :math:`b` to the
function `call_func_ab` already during definition so that ``pyeee``
can then simply call it as `func(x)`, so that `x` is passed to
`call_func_ab` as well.
Figuratively speaking, `partial` passes :math:`a` and :math:`b` to the function `call_func_ab`
already during definition so that ``pyeee`` can then simply call it as `func(x)`, so that `x` is
passed to `call_func_ab` as well.


Function wrappers
-----------------

``pyeee`` provides wrappers to use with partial.
We recommend to use the package :mod:`partialwrap`, which provides wrappers to use with partial.

.. code-block:: python
from pyeee.utils import func_wrapper
from partialwrap import function_wrapper
args = [a, b]
kwargs = {}
func = partial(func_wrapper, ishigami, args, kwargs)
func = partial(function_wrapper, ishigami, args, kwargs)
# screen
np.random.seed(seed=1021) # for reproducibility of examples
out = eee(func, lb, ub)
There are wrappers to use with Python functions with or without
masking parameters, as well as wrappers for external executables.
masking parameters, as well as wrappers for external programs.


Installation
Expand Down
2 changes: 1 addition & 1 deletion docs/source/morris_method.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pyeee.morris
=================
============

.. automodule:: pyeee.morris_method
:members:
Expand Down
Loading

0 comments on commit 3bd7bcf

Please sign in to comment.