Skip to content

Commit

Permalink
Merge branch '0.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarno Lintusaari committed Sep 11, 2017
2 parents 3d4fe94 + 54e62b2 commit 53effb0
Show file tree
Hide file tree
Showing 74 changed files with 3,156 additions and 1,541 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Changelog
==========
=========

0.6.2 (2017-09-06)
------------------

- Easier saving and loading of ElfiModel
- Renamed elfi.set_current_model to elfi.set_default_model
- Renamed elfi.get_current_model to elfi.get_default_model
- Improved performance when rerunning inference using stored data
- Change SMC to use ModelPrior, use to immediately reject invalid proposals

0.6.1 (2017-07-21)
------------------
Expand Down
24 changes: 9 additions & 15 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ Ready to contribute? Here's how to set up `ELFI` for local development.

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

3. Install your local copy and the development requirements into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development. Due to a bug in the pip installation of GPy numpy needs to be installed manually.::
3. Install your local copy and the development requirements into a conda environment::

$ mkvirtualenv elfi
$ cd elfi/
$ pip install numpy
$ conda create -n elfi python=3.5 numpy
$ source activate elfi
$ cd elfi
$ make dev

4. Create a branch for local development::
Expand All @@ -84,7 +84,7 @@ Ready to contribute? Here's how to set up `ELFI` for local development.
$ make lint
$ make test

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

$ make docs

Expand All @@ -99,26 +99,20 @@ Ready to contribute? Here's how to set up `ELFI` for local development.
Style Guidelines
----------------

The projects follows the `Khan Academy Style Guide <https://github.com/Khan/style-guides/blob/master/style/python.md>`_. Except that we use numpy style docstrings instead of Google style docstrings.
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.

See `this example <http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html>`_ for how to format the docstrings.
Docstrings follow the `NumPy style <http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html>`_.

Additional Style Guidelines
~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Use the ``.format()`` string method instead of the old percent operator. For more information see `PyFormat <https://pyformat.info/>`_.
- Use the type hinting syntax suggested `here <https://www.jetbrains.com/help/pycharm/2016.1/type-hinting-in-pycharm.html>`_ in the docstrings.

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

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

1. The pull request should include tests.
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.
3. The pull request should work for Python 2.7, 3.5 and later. Check
3. The pull request should work for Python 3.5 and later. Check
https://travis-ci.org/elfi-dev/elfi/pull_requests
and make sure that the tests pass for all supported Python versions.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ docs: ## generate Sphinx HTML documentation, including API docs
$(MAKE) -C docs html
# $(BROWSER) docs/_build/html/index.html

CONTENT_URL := http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.1/
CONTENT_URL := http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.2/

notebook-docs: ## Conver notebooks to rst docs. Assumes you have them in `notebooks` directory.
jupyter nbconvert --to rst ../notebooks/quickstart.ipynb --output-dir docs
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.6.1 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).
**Version 0.6.2 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).

ELFI - Engine for Likelihood-Free Inference
===========================================
Expand Down
5 changes: 3 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ Below is the API for creating generative models.

.. autosummary::
elfi.new_model
elfi.get_current_model
elfi.set_current_model
elfi.load_model
elfi.get_default_model
elfi.set_default_model

.. currentmodule:: elfi.visualization.visualization

Expand Down
20 changes: 10 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,34 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os

import sys
# http://docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules
from unittest.mock import MagicMock


class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return MagicMock()
return MagicMock()


on_RTD = os.environ.get('READTHEDOCS', None) == 'True'
if on_RTD:
MOCK_MODULES = ['pygtk', 'gtk', 'gobject', 'argparse', 'numpy', 'pandas', 'scipy',
'unqlite', 'dask', 'distributed', 'distributed.client', 'graphviz', 'matplotlib',
'sobol_seq', 'GPy', 'dask.delayed', 'scipy.optimize', 'scipy.stats',
'scipy.spatial', 'scipy.sparse', 'matplotlib.pyplot', 'numpy.random', 'networkx',
'ipyparallel', 'numpy.lib', 'numpy.lib.format', 'sklearn.linear_model']
MOCK_MODULES = [
'pygtk', 'gtk', 'gobject', 'argparse', 'numpy', 'pandas', 'scipy', 'unqlite', 'dask',
'distributed', 'distributed.client', 'graphviz', 'matplotlib', 'sobol_seq', 'GPy',
'dask.delayed', 'scipy.optimize', 'scipy.stats', 'scipy.spatial', 'scipy.sparse',
'matplotlib.pyplot', 'numpy.random', 'networkx', 'ipyparallel', 'numpy.lib',
'numpy.lib.format', 'sklearn.linear_model'
]
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

html_theme = 'default'

else:
html_theme = 'sphinx_rtd_theme'


# https://github.com/rtfd/readthedocs.org/issues/1139
"""
def run_apidoc(_):
Expand Down Expand Up @@ -179,7 +180,6 @@ def setup(app):
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down
20 changes: 10 additions & 10 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ First ensure you have
Python 3.5 (or greater) and ELFI. After installation you can start using
ELFI:

.. code:: python
.. code:: ipython3
import elfi
ELFI includes an easy to use generative modeling syntax, where the
generative model is specified as a directed acyclic graph (DAG). Let’s
create two prior nodes:

.. code:: python
.. code:: ipython3
mu = elfi.Prior('uniform', -2, 4)
sigma = elfi.Prior('uniform', 1, 4)
Expand All @@ -30,7 +30,7 @@ summary statistics for the data. As an example, lets define the
simulator as 30 draws from a Gaussian distribution with a given mean and
standard deviation. Let's use mean and variance as our summaries:

.. code:: python
.. code:: ipython3
import scipy.stats as ss
import numpy as np
Expand All @@ -48,7 +48,7 @@ standard deviation. Let's use mean and variance as our summaries:
Let’s now assume we have some observed data ``y0`` (here we just create
some with the simulator):

.. code:: python
.. code:: ipython3
# Set the generating parameters that we will try to infer
mean0 = 1
Expand All @@ -73,7 +73,7 @@ Now we have all the components needed. Let’s complete our model by
adding the simulator, the observed data, summaries and a distance to our
model:

.. code:: python
.. code:: ipython3
# Add the simulator node and observed data to the model
sim = elfi.Simulator(simulator, mu, sigma, observed=y0)
Expand All @@ -89,15 +89,15 @@ model:
If you have ``graphviz`` installed to your system, you can also
visualize the model:

.. code:: python
.. code:: ipython3
# Plot the complete model (requires graphviz)
elfi.draw(d)
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.1/quickstart_files/quickstart_11_0.svg
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.2/quickstart_files/quickstart_11_0.svg



Expand All @@ -108,7 +108,7 @@ We can try to infer the true generating parameters ``mean0`` and
Rejection sampling and sample 1000 samples from the approximate
posterior using threshold value 0.5:

.. code:: python
.. code:: ipython3
rej = elfi.Rejection(d, batch_size=10000, seed=30052017)
res = rej.sample(1000, threshold=.5)
Expand All @@ -127,13 +127,13 @@ posterior using threshold value 0.5:
Let's plot also the marginal distributions for the parameters:

.. code:: python
.. code:: ipython3
import matplotlib.pyplot as plt
res.plot_marginals()
plt.show()
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.1/quickstart_files/quickstart_16_0.png
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.2/quickstart_files/quickstart_16_0.png

0 comments on commit 53effb0

Please sign in to comment.