Skip to content

Commit

Permalink
Merge pull request #317 from elfi-dev/dev
Browse files Browse the repository at this point in the history
Release v. 0.7.5

- Improved the appearance of figures produced by `plot_gp` and added the option
  to draw true parameter indicators on the subplots using the optional input
  `true_params`
- Modified DCC model by taking into account that subject can't infect herself
- Added ability to set minimizer constrains for BOLFI
- Enable bolfi.fit using only pre-generated initial evidence points
- Fixed a bug causing random seed number to be deterministic
- Updated requirements-dev.txt with pytest>=4.4
- Minor changes to documentation and refactoring
- Added `make test-notslow` alternative
  • Loading branch information
hpesonen authored Dec 18, 2019
2 parents b07ff6e + 21a9121 commit 08f3099
Show file tree
Hide file tree
Showing 27 changed files with 243 additions and 117 deletions.
12 changes: 10 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
Please provide a short summary here

#### Please make sure
- You have updated the CHANGELOG.rst
- You have updated the documentation (if applicable)

- [ ] You have updated the CHANGELOG.rst
- [ ] You have provided a short summary of your changes (see previous section)
- [ ] You have listed the copyright holder for the work you are submitting (see next section)

If your contribution adds, removes or somehow changes the functional behavior of the package, please check that

- [ ] You have included or updated all the relevant documentation
- [ ] The proposed changes pass all unit tests (check step 6 of CONTRIBUTING.rst for details)
- [ ] You have added appropriate unit tests to ensure the new features behave as expected

#### Copyright and Licensing

Expand Down
42 changes: 32 additions & 10 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
Changelog
=========

0.7.5 (2019-12-18)
------------------
- Improved the appearance of figures produced by `plot_gp` and added the option
to draw true parameter indicators on the subplots using the optional input
`true_params`
- Modified DCC model by taking into account that subject can't infect herself
- Added ability to set minimizer constrains for BOLFI
- Enable bolfi.fit using only pre-generated initial evidence points
- Fixed a bug causing random seed number to be deterministic
- Updated requirements-dev.txt with pytest>=4.4
- Minor changes to documentation and refactoring
- Added `make test-notslow` alternative

0.7.4 (2019-03-07)
------------------
- Add sampler option `algorithm` for bolfi-posterior-sampling
- Add a check whether the option given for `algorithm` is one if the implemented samplers
- Add a check whether the option given for `algorithm` is one if the
implemented samplers
- Add metropolis sampler `algorithm=metropolis` for bolfi-posterior-sampling
- Add option `warmup` to metropolis-sampler
- Add a small test of metropolis-sampler
Expand All @@ -17,7 +30,8 @@ Changelog
0.7.3 (2018-08-30)
------------------
- Fix bug in plot_pairs which crashes in case of 1 parameter
- Fix bug in plot_marginals which outputs empty plots in case where we have parameter more than 5
- Fix bug in plot_marginals which outputs empty plots in case where we have
parameter more than 5
- Fix crashing summary and plots for samples with multivariate priors
- Add progress bar for inference methods
- Add method save to Sample objects
Expand All @@ -27,7 +41,8 @@ Changelog
0.7.2 (2018-06-20)
------------------
- Added support for kwargs in elfi.set_client
- Added new example: inference of transmission dynamics of bacteria in daycare centers
- Added new example: inference of transmission dynamics of bacteria in daycare
centers
- Added new example: Lorenz model

0.7.1 (2018-04-11)
Expand All @@ -40,19 +55,22 @@ Changelog
----------------
- Added new example: the stochastic Lotka-Volterra model
- Fix methods.bo.utils.minimize to be strictly within bounds
- Implemented the Two Stage Procedure, a method of summary-statistics diagnostics
- Implemented the Two Stage Procedure, a method of summary-statistics
diagnostics
- Added the MaxVar acquisition method
- Added the RandMaxVar acquisition method
- Added the ExpIntVar acquisition method
- Implemented the Two Stage Procedure, a method of summary-statistics diagnostics
- Implemented the Two Stage Procedure, a method of summary-statistics
diagnostics
- Added new example: the stochastic Lotka-Volterra model
- Fix methods.bo.utils.minimize to be strictly within bounds
- Fix elfi.Distance to support scipy 1.0.0

0.6.3 (2017-09-28)
------------------

- Further performance improvements for rerunning inference using stored data via caches
- Further performance improvements for rerunning inference using stored data
via caches
- Added the general Gaussian noise example model (fixed covariance)
- restrict NetworkX to versions < 2.0

Expand All @@ -74,18 +92,21 @@ Changelog
- Added OutputPool.open to read a closed pool from disk
- Refactored Sample and SmcSample classes
- Added elfi.new_model method
- Made elfi.set_client method to accept clients as strings for easier client switching
- Made elfi.set_client method to accept clients as strings for easier client
switching
- Fixed a bug in NpyArray that would lead to an inconsistent state if multiple
simultaneous instances were opened.
- Added the ability to move the pool data folder
- Sample.summary is now a method instead of a property
- SmcSample methods takes the keyword argument 'all' to show results of all populations
- SmcSample methods takes the keyword argument 'all' to show results of all
populations
- Added a section about iterative advancing to documentation

0.6 (2017-07-03)
----------------

- Changed some of the internal variable names in methods.py. Most notable outputs is now
- Changed some of the internal variable names in methods.py. Most notable
outputs is now
output_names.
- methods.py renamed to parameter_inference.py
- Changes in elfi.methods.results module class names:
Expand All @@ -108,7 +129,8 @@ Major update, a lot of code base rewritten.
Most important changes:

- revised syntax for model definition (esp. naming)
- scheduler-independent parallelization interface (currently supports native & ipyparallel)
- scheduler-independent parallelization interface (currently supports native &
ipyparallel)
- methods can now be run iteratively
- persistence to .npy files
- Bayesian optimization as a separate method
Expand Down
33 changes: 24 additions & 9 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,61 +54,76 @@ If you are proposing a feature:
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)


Get Started!
------------

`ELFI` is a project with dozens of collaborators, so organization is key to making our contributions effective and avoid reword. Thus, in addition to the recommendations below we strongly recommend reading our `Wiki <https://github.com/elfi-dev/elfi/wiki>`_ to see what is the suggested git workflow procedure for your type of contribution.

Ready to contribute? Here's how to set up `ELFI` for local development.

1. Fork the `elfi` repo on GitHub.
2. Clone your fork locally::

$ git clone git@github.com:your_name_here/elfi.git

3. Install your local copy and the development requirements into a conda environment::
3. Make sure you have `Python 3 <https://www.python.org/>`_ and
`Anaconda Distribution <https://www.anaconda.com/>`_ installed on your
machine. Check your conda and Python versions::

$ conda -V
$ python -V

4. Install your local copy and the development requirements into a conda
environment. You may need to replace "3.5" in the first line with the python
version printed in the previous step::

$ conda create -n elfi python=3.5 numpy
$ source activate elfi
$ cd elfi
$ make dev

4. Create a branch for local development::
5. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.
5. Follow the `Style Guidelines`_

6. When you're done making changes, check that your changes pass flake8 and the tests::
6. Follow the `Style Guidelines`_

7. When you're done making changes, check that your changes pass flake8 and the tests::

$ make lint
$ make test

You may run `make test-notslow` instead of `make test` *as long as your proposed changes are unrelated to BOLFI*.

Also make sure that the docstrings of your code are formatted properly::

$ make docs

7. Commit your changes and push your branch to GitHub::
8. Commit your changes and push your branch to GitHub::

$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

8. Submit a pull request through the GitHub website.
9. Submit a pull request through the GitHub website.

Style Guidelines
----------------

The Python code in ELFI mostly follows `PEP8 <http://pep8.org/>`_, which is considered the de-facto code style guide for Python. Lines should not exceed 100 characters.

Docstrings follow the `NumPy style <http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html>`_.

Pull Request Guidelines
-----------------------

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests that will be run automatically using Travis-CI.
1. The pull request should include tests that will be run automatically using
Travis-CI.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ lint: ## check style with flake8
flake8 elfi tests

test: ## run tests quickly with the default Python
PYTHONPATH=$$PYTHONPATH:. py.test --reruns 1
PYTHONPATH=$$PYTHONPATH:. pytest --reruns 1

test-notslow: ## skips tests marked as slowtest
PYTHONPATH=$$PYTHONPATH:. pytest -m "not slowtest"

test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
py.test --cov=elfi
pytest --cov=elfi
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**Version 0.7.4 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).
**Version 0.7.5 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).

**NOTE:** For the time being NetworkX 2 is incompatible with ELFI.

Expand Down
1 change: 0 additions & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Quickstart
==========

Expand Down
1 change: 0 additions & 1 deletion docs/usage/BOLFI.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

This tutorial is generated from a `Jupyter <http://jupyter.org/>`__
notebook that can be found
`here <https://github.com/elfi-dev/notebooks>`__.
Expand Down
5 changes: 2 additions & 3 deletions docs/usage/external.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

This tutorial is generated from a `Jupyter <http://jupyter.org/>`__
notebook that can be found
`here <https://github.com/elfi-dev/notebooks>`__.
Expand Down Expand Up @@ -128,7 +127,7 @@ population size:
It is assumed that the susceptible population is infinite, the hosts
carry only one mutation of the disease and transmit that mutation
onward. A more accurate description of the model can be found from the
original paper or e.g. `Lintusaari at al
original paper or e.g. `Lintusaari at al
2016 <https://doi.org/10.1093/sysbio/syw077>`__ *[1]*.

.. For documentation
Expand Down Expand Up @@ -625,6 +624,6 @@ References
Kaski, Jukka Corander; Fundamentals and Recent Developments in
Approximate Bayesian Computation. Syst Biol 2017; 66 (1): e66-e82.
doi: 10.1093/sysbio/syw077
- [2] Tanaka, Mark M., et al. “Using approximate Bayesian computation
- [2] Tanaka, Mark M., et al. “Using approximate Bayesian computation
to estimate tuberculosis transmission parameters from genotype data.”
Genetics 173.3 (2006): 1511-1520.
2 changes: 1 addition & 1 deletion docs/usage/parallelization.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

This tutorial is generated from a `Jupyter <http://jupyter.org/>`__
notebook that can be found
`here <https://github.com/elfi-dev/notebooks>`__.
Expand Down Expand Up @@ -301,3 +300,4 @@ Remember to stop the ipcluster when done
2018-04-24 19:14:56.997 [IPClusterStop] Stopping cluster [pid=39639] with [signal=<Signals.SIGINT: 2>]
30 changes: 15 additions & 15 deletions docs/usage/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

This tutorial is generated from a `Jupyter <http://jupyter.org/>`__
notebook that can be found
`here <https://github.com/elfi-dev/notebooks>`__.
Expand Down Expand Up @@ -95,8 +94,8 @@ scalars as they are first converted to vectors.
.. Important:: In order to guarantee a consistent state of pseudo-random number generation, the simulator must have `random_state` as a keyword argument for reading in a `numpy.RandomState` object.

Let’s now use this simulator to create toy observations. We will use
parameter values :math:`\theta_1=0.6, \theta_2=0.2` as in `Marin et al.
(2012) <http://link.springer.com/article/10.1007/s11222-011-9288-2>`__
parameter values :math:`\theta_1=0.6, \theta_2=0.2` as in `Marin et
al. (2012) <http://link.springer.com/article/10.1007/s11222-011-9288-2>`__
and then try to infer these parameter values back based on the toy
observed data alone.

Expand Down Expand Up @@ -142,7 +141,7 @@ have been produced by similar parameters. Looking at the picture above,
in essence we would keep simulating until we have found enough sequences
that are similar to the observed sequence. Although the idea may appear
inapplicable for the task at hand, you will soon see that it does work.
For more information about ABC, please see e.g.
For more information about ABC, please see e.g. 

- `Lintusaari, J., Gutmann, M. U., Dutta, R., Kaski, S., and Corander,
J. (2016). Fundamentals and recent developments in approximate
Expand Down Expand Up @@ -261,8 +260,8 @@ Modifying the model
-------------------

Although the above definition is perfectly valid, let’s use the same
priors as in `Marin et al.
(2012) <http://link.springer.com/article/10.1007/s11222-011-9288-2>`__
priors as in `Marin et
al. (2012) <http://link.springer.com/article/10.1007/s11222-011-9288-2>`__
that guarantee that the problem will be identifiable (loosely speaking,
the likelihood willl have just one mode). Marin et al. used priors for
which :math:`-2<\theta_1<2` with :math:`\theta_1+\theta_2>-1` and
Expand Down Expand Up @@ -532,12 +531,12 @@ applicable.
Storing simulated data
----------------------

As the samples are already in numpy arrays, you can just say e.g.
``np.save('t1_data.npy', result.samples['t1'])`` to save them. However,
ELFI provides some additional functionality. You may define a *pool* for
storing all outputs of any node in the model (not just the accepted
samples). Let’s save all outputs for ``t1``, ``t2``, ``S1`` and ``S2``
in our model:
As the samples are already in numpy arrays, you can just say
e.g. ``np.save('t1_data.npy', result.samples['t1'])`` to save them.
However, ELFI provides some additional functionality. You may define a
*pool* for storing all outputs of any node in the model (not just the
accepted samples). Let’s save all outputs for ``t1``, ``t2``, ``S1`` and
``S2`` in our model:

.. code:: ipython3
Expand Down Expand Up @@ -758,9 +757,9 @@ Often “pairwise relationships” are more informative:
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.2/usage/tutorial_files/tutorial_79_0.png


Note that if working in a non-interactive environment, you can use e.g.
``plt.savefig('pairs.png')`` after an ELFI plotting command to save the
current figure to disk.
Note that if working in a non-interactive environment, you can use
e.g. ``plt.savefig('pairs.png')`` after an ELFI plotting command to save
the current figure to disk.

Sequential Monte Carlo ABC
--------------------------
Expand Down Expand Up @@ -1013,3 +1012,4 @@ practices with ELFI.
That’s it! See the other documentation for more advanced topics on
e.g. BOLFI, external simulators and parallelization.

2 changes: 1 addition & 1 deletion elfi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
__email__ = 'elfi-support@hiit.fi'

# make sure __version_ is on the last non-empty line (read by setup.py)
__version__ = '0.7.4'
__version__ = '0.7.5'
Loading

0 comments on commit 08f3099

Please sign in to comment.