Skip to content

Commit ce02414

Browse files
authored
Merge pull request #276 from elfi-dev/dev
Release 0.7.2
2 parents b5807b1 + e6ed1d6 commit ce02414

20 files changed

+1017
-86
lines changed

.dockerignore

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# IDE settings
2+
.idea
3+
4+
# Byte-compiled / optimized / DLL files
5+
**/__pycache__
6+
*.py[cod]
7+
*$py.class
8+
9+
# C/C++ extensions
10+
*.so
11+
*.bin
12+
13+
# Distribution / packaging
14+
.Python
15+
env
16+
build
17+
develop-eggs
18+
dist
19+
downloads
20+
eggs
21+
.eggs
22+
lib
23+
lib64
24+
parts
25+
sdist
26+
var
27+
*.egg-info
28+
.installed.cfg
29+
*.egg
30+
31+
# Images
32+
*.png
33+
*.svg
34+
*.jpg
35+
*.jpeg
36+
37+
# PyInstaller
38+
# Usually these files are written by a python script from a template
39+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
40+
*.manifest
41+
*.spec
42+
43+
# Installer logs
44+
pip-log.txt
45+
pip-delete-this-directory.txt
46+
47+
# Unit test / coverage reports
48+
htmlcov/
49+
.tox
50+
.coverage
51+
.coverage.*
52+
.cache
53+
nosetests.xml
54+
coverage.xml
55+
*cover
56+
.hypothesis
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
local_settings.py
65+
66+
# Flask stuff:
67+
instance
68+
.webassets-cache
69+
70+
# Scrapy stuff:
71+
.scrapy
72+
73+
# Sphinx documentation
74+
docs/_build
75+
76+
# PyBuilder
77+
target
78+
79+
# IPython Notebook
80+
.ipynb_checkpoints
81+
82+
# pyenv
83+
.python-version
84+
85+
# celery beat schedule file
86+
celerybeat-schedule
87+
88+
# dotenv
89+
.env
90+
91+
# virtualenv
92+
venv
93+
ENV
94+
.venv
95+
96+
# Spyder project settings
97+
.spyderproject
98+
99+
# Rope project settings
100+
.ropeproject
101+
102+
# Editor temp files
103+
*~
104+
*.swo
105+
*.swp
106+

CHANGELOG.rst

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
0.7.2 (2018-06-20)
5+
------------------
6+
- Added support for kwargs in elfi.set_client
7+
- Added new example: inference of transmission dynamics of bacteria in daycare centers
8+
- Added new example: Lorenz model
9+
410
0.7.1 (2018-04-11)
511
------------------
612
- Implemented model selection (elfi.compare_models). See API documentation.

Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.6
2+
3+
RUN apt-get update && apt-get install -y graphviz
4+
5+
WORKDIR /elfi
6+
ADD . /elfi
7+
8+
RUN pip install numpy graphviz
9+
RUN pip install -e .
10+
RUN pip install -r requirements-dev.txt
11+
12+
# matplotlib unable to show figures
13+
RUN mkdir -p /root/.config/matplotlib
14+
RUN echo "backend : Agg" >> /root/.config/matplotlib/matplotlibrc
15+
16+
CMD ["/bin/bash"]

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ lint: ## check style with flake8
5252
flake8 elfi tests
5353

5454
test: ## run tests quickly with the default Python
55-
PYTHONPATH=$$PYTHONPATH:. py.test
55+
PYTHONPATH=$$PYTHONPATH:. py.test --reruns 1
5656

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

README.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**Version 0.7.1 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).
1+
**Version 0.7.2 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).
22

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

@@ -75,6 +75,17 @@ source activate elfi
7575
pip install elfi
7676
```
7777

78+
### Docker container
79+
80+
A simple Dockerfile for command-line interface is also provided. Please see [Docker documentation](https://docs.docker.com/).
81+
82+
```
83+
git clone --depth 1 https://github.com/elfi-dev/elfi.git
84+
cd elfi
85+
docker build -t elfi .
86+
docker run -it elfi
87+
```
88+
7889
### Potential problems with installation
7990

8091
ELFI depends on several other Python packages, which have their own dependencies.
@@ -94,9 +105,9 @@ If you wish to cite ELFI, please use the paper in [arXiv](https://arxiv.org/abs/
94105

95106
```
96107
@misc{1708.00707,
97-
Author = {Jarno Lintusaari and Henri Vuollekoski and Antti Kangasrääsiö and Kusti Skytén and Marko Järvenpää and Michael Gutmann and Aki Vehtari and Jukka Corander and Samuel Kaski},
108+
Author = {Jarno Lintusaari and Henri Vuollekoski and Antti Kangasrääsiö and Kusti Skytén and Marko Järvenpää and Pekka Marttinen and Michael Gutmann and Aki Vehtari and Jukka Corander and Samuel Kaski},
98109
Title = {ELFI: Engine for Likelihood Free Inference},
99-
Year = {2017},
110+
Year = {2018},
100111
Eprint = {arXiv:1708.00707},
101112
}
102113
```

docs/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ If you wish to cite ELFI, please use the paper in arXiv_:
8282
.. code-block:: console
8383
8484
@misc{1708.00707,
85-
Author = {Jarno Lintusaari and Henri Vuollekoski and Antti Kangasrääsiö and Kusti Skytén and Marko Järvenpää and Michael Gutmann and Aki Vehtari and Jukka Corander and Samuel Kaski},
85+
Author = {Jarno Lintusaari and Henri Vuollekoski and Antti Kangasrääsiö and Kusti Skytén and Marko Järvenpää and Pekka Marttinen and Michael Gutmann and Aki Vehtari and Jukka Corander and Samuel Kaski},
8686
Title = {ELFI: Engine for Likelihood Free Inference},
87-
Year = {2017},
87+
Year = {2018},
8888
Eprint = {arXiv:1708.00707},
8989
}

docs/installation.rst

+13
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,16 @@ means the current folder.
8989
.. _Github repo: https://github.com/elfi-dev/elfi
9090
.. _tarball: https://github.com/elfi-dev/elfi/tarball/dev
9191

92+
Docker container
93+
----------------
94+
95+
A simple Dockerfile for command-line interface is also provided. Please see `Docker documentation`_.
96+
97+
.. _Docker documentation: https://docs.docker.com/
98+
99+
.. code-block:: console
100+
101+
git clone --depth 1 https://github.com/elfi-dev/elfi.git
102+
cd elfi
103+
docker build -t elfi .
104+
docker run -it elfi

docs/usage/parallelization.rst

+63-14
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ in your computer. You can activate it simply by
5656
5757
elfi.set_client('multiprocessing')
5858
59-
Any inference instance created after you have set the new client will
60-
automatically use it to perform the computations. Let's try it with our
61-
MA2 example model from the tutorial. When running the next command, take
62-
a look at the system monitor of your operating system; it should show
63-
that all of your cores are doing heavy computation simultaneously.
59+
Any inference instance created **after** you have set the new client
60+
will automatically use it to perform the computations. Let's try it with
61+
our MA2 example model from the tutorial. When running the next command,
62+
take a look at the system monitor of your operating system; it should
63+
show that all of your cores are doing heavy computation simultaneously.
6464

6565
.. code:: ipython3
6666
@@ -70,8 +70,8 @@ that all of your cores are doing heavy computation simultaneously.
7070
7171
.. parsed-literal::
7272
73-
CPU times: user 272 ms, sys: 28 ms, total: 300 ms
74-
Wall time: 2.41 s
73+
CPU times: user 298 ms, sys: 25.7 ms, total: 324 ms
74+
Wall time: 3.93 s
7575
7676
7777
And that is it. The result object is also just like in the basic case:
@@ -91,14 +91,63 @@ And that is it. The result object is also just like in the basic case:
9191
Method: Rejection
9292
Number of samples: 5000
9393
Number of simulations: 1000000
94-
Threshold: 0.0817
95-
Sample means: t1: 0.68, t2: 0.133
94+
Threshold: 0.0826
95+
Sample means: t1: 0.694, t2: 0.226
9696
9797
9898
9999
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.2/usage/parallelization_files/parallelization_11_1.png
100100

101101

102+
Note that for reproducibility a reference to the activated client is
103+
saved in the inference instance:
104+
105+
.. code:: ipython3
106+
107+
rej.client
108+
109+
110+
111+
112+
.. parsed-literal::
113+
114+
<elfi.clients.multiprocessing.Client at 0x1a19c2f128>
115+
116+
117+
118+
If you want to change the client for an existing inference instance, you
119+
have to do something like this:
120+
121+
.. code:: ipython3
122+
123+
elfi.set_client('native')
124+
rej.client = elfi.get_client()
125+
rej.client
126+
127+
128+
129+
130+
.. parsed-literal::
131+
132+
<elfi.clients.native.Client at 0x1a1d2a5cf8>
133+
134+
135+
136+
By default the multiprocessing client will use all cores on your system.
137+
This is not always desirable, as the operating system may prioritize
138+
some other process, leaving ELFI queuing for the promised resources. You
139+
can define some other number of processes like so:
140+
141+
.. code:: ipython3
142+
143+
elfi.set_client(elfi.clients.multiprocessing.Client(num_processes=3))
144+
145+
**Note:** The ``multiprocessing`` library may require additional care
146+
under Windows. If you receive a RuntimeError mentioning
147+
``freeze_support``, please include a call to
148+
``multiprocessing.freeze_support()``, see
149+
`documentation <https://docs.python.org/3.6/library/multiprocessing.html#multiprocessing.freeze_support>`__.
150+
102151
Ipyparallel client
103152
------------------
104153

@@ -136,8 +185,8 @@ take care of the parallelization from now on:
136185
137186
.. parsed-literal::
138187
139-
CPU times: user 3.16 s, sys: 184 ms, total: 3.35 s
140-
Wall time: 13.4 s
188+
CPU times: user 3.47 s, sys: 288 ms, total: 3.76 s
189+
Wall time: 18.1 s
141190
142191
143192
To summarize, the only thing that needed to be changed from the basic
@@ -230,8 +279,8 @@ The above may look a bit cumbersome, but now this works:
230279
Method: Rejection
231280
Number of samples: 1000
232281
Number of simulations: 100000
233-
Threshold: 0.0136
234-
Sample means: t1: 0.676, t2: 0.129
282+
Threshold: 0.0146
283+
Sample means: t1: 0.693, t2: 0.233
235284
236285
237286
@@ -250,5 +299,5 @@ Remember to stop the ipcluster when done
250299
251300
.. parsed-literal::
252301
253-
2017-07-19 16:20:58.662 [IPClusterStop] Stopping cluster [pid=21020] with [signal=<Signals.SIGINT: 2>]
302+
2018-04-24 19:14:56.997 [IPClusterStop] Stopping cluster [pid=39639] with [signal=<Signals.SIGINT: 2>]
254303

0 commit comments

Comments
 (0)