Skip to content

Commit

Permalink
Merge pull request #362 from ConnectedSystems/develop
Browse files Browse the repository at this point in the history
Latest dev version
  • Loading branch information
ConnectedSystems committed Sep 30, 2020
2 parents 2689340 + e34e7a4 commit 2a5c0d3
Show file tree
Hide file tree
Showing 70 changed files with 4,257 additions and 1,383 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Based on: https://github.com/fcakyon/conda-publish-action

name: SALib Python Package using Conda

on:
push:
branches:
- master
tags:
- "*v*"

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
$CONDA/bin/conda env update --file environment.yml --name base
- name: Lint with flake8
run: |
$CONDA/bin/conda install flake8
# stop the build if there are Python syntax errors or undefined names
$CONDA/bin/flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
$CONDA/bin/flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
conda install pytest
$CONDA/bin/pytest
43 changes: 43 additions & 0 deletions .github/workflows/test-pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload SALib Python Package pre-release to PyPI and TestPyPI

on:
push:
branches:
- "develop"
tags:
- "*dev*"

jobs:
pre-release:
name: "Pre Release"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
45 changes: 45 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow creates a PR with an automatically updated changelog
# Based on: https://github.com/marketplace/actions/update-changelog

name: Update changelog for release candidates

on:
push:
branches:
- "release-candidate"
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.8"
- name: Update version
id: version
run: |
echo "GITHUB_REF is a tag you set for the release"
echo "Your GitHub ref: ${GITHUB_REF}"
VERSION=`echo "${GITHUB_REF}" | cut -f 3 -d "/"`
echo "Preparing version ${VERSION}"
echo "__version__ = \"${VERSION}\"" > __version__.py
echo "##[set-output name=version;]$(echo ${VERSION})"
- uses: vemel/update-changelog@0.0.1
id: changelog
with:
version: ${{ steps.version.outputs.version }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v2
with:
commit-message: Release ${{ steps.version.outputs.version }}
labels: release, bot
title: "Release ${{ steps.version.outputs.version }}"
body: |
# Release ${{ steps.version.outputs.version }}
Merge this PR to update your version and changelog!
## Included Pull Requests
${{ steps.changelog.outputs.pulls_list_md }}
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Developers
* Fernando Rios
* Dan Hyams
* xantares
* Abdullah Sahin <sahina@uci.edu>
151 changes: 151 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Changelog

This changelog follows the format defined at:
https://keepachangelog.com/en/1.0.0/

## [1.3.0]

### Added

- Various minor performance enhancements (PR #253 #264)
- Added some visualisation methods (PR #259)
- Tidying up of the Command Line Interfance, and num samples (PR #260 #291)
- Improved efficiency of summing distances in local optimization (PR #246)
- Revamped fast method for consistency (PR #239)
- Updated Sobol-G function to modified G-function (#269)

### Bug Fixes:

- Method of morris didn't adjust with levels above 4 (PR #252)
- Add missing seed option for morris sampling
- Handle singular value matrix cases (PR #251)
- Fixed typo (#205)
- Updated import of scipy comb function (PR #243)

### Documentation:

- Update documentation for Morris and DSGM methods (#261 #266)

### Development Features:

- Updated PyScaffold to version 3.2.2 (#267)
- Updated Travis and package config (#285)

## [1.1.0]

### New Features:

- Refactored Method of Morris so the Ruano et al. local approach is default

### Bug Fixes:

- Inputs to morris.analyze are provided as floats
- Removed calls to standard random library as inconsistent between Python 2 & 3
- First row in Sobol sequences should be zero, not empty

### Documentation:

- Added a Code of Conduct
- Added DAETools, BCMD and others to citations - thanks for using SALib!
- Removed misleading keyword arguments in docs and readme examples
- Updated documentation for Method of Morris following refactor
- Improved existing documentation where lacking e.g. for fractional factorial
method

### Development Features:

- Implemented automatic deployment to PyPi
- Fixed a bug preventing automatic deployment to PyPi upon tagging a branch
- Removed postgres from travis config

## [1.0.0]

Release of our stable version of SALIB to coincide with an submission to JOSS:

- Added a paper for submission to the Journal of Open-source Software
- Updated back-end for documentation on read-the-docs
- Updated the back-end for version introspection using PyScaffold, rather than
versioneer
- Updated the Travis-CI scripts
- Moved the tests out of the SALib package and migrated to using pytest

## [0.7.1]

Improvements to Morris sampling and Sobol groups/distributions

- Adds improved sampling for the Morris method
(thanks to @JoerivanEngelen) and group sampling/analysis for the Sobol method
(thanks to @calvinwhealton).
- @calvinwhealton has also added non-uniform distributions to the Sobol
sampling. This will be a baseline for adding this to the other methods in
the future.
- Also includes several minor bug fixes.

## [0.7.0]

New documentation, doc strings and installation requirements

- @dhadka has kindly contributed a wealth of documentation to the project,
including doc strings in every module
- no longer test for numpy <1.8.0 and matplotlib < 1.4.3, and these
requirements are implemented in a new setup script.

## [0.6.3]

Parallel option for Sobol method

- New option to run analyze.sobol function in parallel using multiprocessing

## [0.6.2]

This release does not contain any new functionality, but SALib now is citable
using a Digital Object Identifier (DOI), which can be found in the readme.

Some minor updates are included:

- morris: sigma has been removed from the grouped-morris results and plots,
replaced by mu_star_conf - a bootstrapped confidence interval.
Mu_star_conf is not equivalent to sigma when used in the non-grouped method of
morris, but its all we have when using groups.
- some minor updates to the tests in the plotting module

## [0.6.0]

- Set up to include and test plotting functions
- Specific plotting functions for Morris
- Fractional Factorial SA from Saltelli et al.
- Repo transferred to SALib organization, update setup and URLs
- Small bugfixes

## [0.5.0]

- Vectorized bootstrap calculations for Morris and Sobol
- Optional trajectory optimization with Gurobi, and tests for it
- Several minor bugfixes
- Starting with v0.5, SALib is released under the MIT license.

## [0.4.0]

- Better Python API without requiring file read/write to the OS.
Consistent functional API to sampling methods so that they return numpy
matrices. Analysis methods now accept numpy matrices instead of data file
names. This does not change the CLI at all, but makes it much easier to use
from native Python.
- Also expanded tests for regression and the Sobol method.

## [0.3.0]

Improvements to Morris sampling and analysis methods,
some bugfixes to make consistent with previous versions of the methods.

## [0.2.0]

Improvements to Morris sampling methods (support for group sampling,
and optimized trajectories). Much better test coverage, and fixed Python 3
compatibility.

## [0.1.0]

First numbered release. Contains reasonably well-tested versions of the Sobol,
Morris, and FAST methods. Also contains newer additions of DGSM and delta
methods which are not as well-tested yet. Contains setup.py for installation.
28 changes: 28 additions & 0 deletions FAQ.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# FAQ

## Installation

Q. I get this error when installing SALib 1.3 with Python 2.7
A. SALib 1.3 onwards does not support Python 2.7


## Usage

Q. I've already got results from my Monte Carlo simulation - which technique can I use?
A. DMIM, RBD-FAST, and HDMR methods are sampling scheme independent.

Q. Can you help me with implementing my sensitivity analysis?
A. Check out [the examples here](https://github.com/SALib/SALib/tree/master/examples)

Q. The example(s) use the Ishigami function. How do I use it with my own model?
A.

Q. How do I get my results?
A. Call the `.to_df()` method if you would like Pandas DataFrames.
The numpy array can be obtained via `.analysis`

Q. How can I plot my results?
A. SALib provides some basic plotting functionality. See [the example here](https://github.com/SALib/SALib/tree/master/examples/plotting).



56 changes: 56 additions & 0 deletions README-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,59 @@ The output can then be converted to a Pandas DataFrame for further analysis.
```python
total_Si, first_Si, second_Si = Si.to_df()
```


### Generating alternate distributions

In the [Quick Start](https://github.com/SALib/SALib/tree/master/README.rst) we
generate a uniform sample of parameter space.

```python
from SALib.sample import saltelli
from SALib.analyze import sobol
from SALib.test_functions import Ishigami
import numpy as np

problem = {
'num_vars': 3,
'names': ['x1', 'x2', 'x3'],
'bounds': [[-3.14159265359, 3.14159265359],
[-3.14159265359, 3.14159265359],
[-3.14159265359, 3.14159265359]]
}

param_values = saltelli.sample(problem, 1000)
```

SALib is also capable of generating alternate sampling distributions by
specifying a `dist` entry in the `problem` specification.

As implied in the basic example, a uniform distribution is the default.

When an entry for `dist` is not 'unif', the `bounds` entry does not indicate
parameter bounds but sample-specific metadata.

`bounds` definitions for available distributions:

* unif: uniform distribution
e.g. :code:`[-np.pi, np.pi]` defines the lower and upper bounds
* triang: triangular with width (scale) and location of peak.
Location of peak is in percentage of width.
Lower bound assumed to be zero.

e.g. :code:`[3, 0.5]` assumes 0 to 3, with a peak at 1.5
* norm: normal distribution with mean and standard deviation
* lognorm: lognormal with ln-space mean and standard deviation

An example specification is shown below:

```python
problem = {
'names': ['x1', 'x2', 'x3'],
'num_vars': 3,
'bounds': [[-np.pi, np.pi], [1.0, 0.2], [3, 0.5]],
'groups': ['G1', 'G2', 'G1'],
'dists': ['unif', 'lognorm', 'triang']
}
```

0 comments on commit 2a5c0d3

Please sign in to comment.