Skip to content

Commit 9474075

Browse files
Merge pull request #562 from ICB-DCM/develop
Release 0.12.3
2 parents 6c6a138 + ae13bf9 commit 9474075

File tree

10 files changed

+433
-71
lines changed

10 files changed

+433
-71
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
run: tox -e visualization
4646

4747
- name: Coverage
48-
uses: codecov/codecov-action@v1
48+
uses: codecov/codecov-action@v2
4949
with:
5050
token: ${{ secrets.CODECOV_TOKEN }}
5151
file: ./coverage.xml
@@ -84,7 +84,7 @@ jobs:
8484
run: tox -e external
8585

8686
- name: Coverage
87-
uses: codecov/codecov-action@v1
87+
uses: codecov/codecov-action@v2
8888
with:
8989
token: ${{ secrets.CODECOV_TOKEN }}
9090
file: ./coverage.xml
@@ -118,7 +118,7 @@ jobs:
118118
run: tox -e petab
119119

120120
- name: Coverage
121-
uses: codecov/codecov-action@v1
121+
uses: codecov/codecov-action@v2
122122
with:
123123
token: ${{ secrets.CODECOV_TOKEN }}
124124
file: ./coverage.xml
@@ -152,7 +152,7 @@ jobs:
152152
run: tox -e mac
153153

154154
- name: Coverage
155-
uses: codecov/codecov-action@v1
155+
uses: codecov/codecov-action@v2
156156
with:
157157
token: ${{ secrets.CODECOV_TOKEN }}
158158
file: ./coverage.xml
@@ -248,7 +248,7 @@ jobs:
248248
run: tox -e migrate
249249

250250
- name: Coverage
251-
uses: codecov/codecov-action@v1
251+
uses: codecov/codecov-action@v2
252252
with:
253253
token: ${{ secrets.CODECOV_TOKEN }}
254254
file: ./coverage.xml

CHANGELOG.rst

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Release Notes
88
...........
99

1010

11+
0.12.3 (2022-04-05)
12+
-------------------
13+
14+
* Document custom priors (#559)
15+
16+
1117
0.12.2 (2022-03-25)
1218
-------------------
1319

README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Written in Python with support for especially R and Julia.
2222
- **Contact:** https://pyabc.rtfd.io/en/latest/about.html
2323
- **Bug reports:** https://github.com/icb-dcm/pyabc/issues
2424
- **Source code:** https://github.com/icb-dcm/pyabc
25+
- **Cite:** https://pyabc.rtfd.io/en/latest/cite.html
2526

2627
.. |CI| image:: https://github.com/ICB-DCM/pyABC/workflows/CI/badge.svg
2728
:target: https://github.com/ICB-DCM/pyABC/actions

doc/examples.rst

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Algorithms and features
3636

3737
examples/early_stopping.ipynb
3838
examples/resuming.ipynb
39+
examples/custom_priors.ipynb
3940
examples/adaptive_distances.ipynb
4041
examples/informative.ipynb
4142
examples/aggregated_distances.ipynb

doc/examples/custom_priors.ipynb

+364
Large diffs are not rendered by default.

doc/installation.rst

+21-58
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,28 @@
33
Install und Upgrade
44
===================
55

6-
76
Preparation
87
-----------
98

109
This package requires Python 3.8 or later.
11-
The package is tested on Linux (using Travis continuous integration).
12-
13-
Not all of the package's functionality is available for Microsoft Windows.
14-
As some of the multi-core parallelizations rely on forking,
15-
these won't work on Windows.
16-
However, most other parts of the
17-
package should work on Windows
18-
as well.
10+
The package is continuously tested on Linux, and in parts on iOS,
11+
via GitHub Actions.
1912

13+
While many parts of the package should work on Microsoft Windows
14+
as well, in particular the multi-core parallelizations rely on forking,
15+
which won't be available.
16+
Still, the main development focus is on Linux.
2017

2118
My system's Python distribution is outdated, what now?
2219
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2320

24-
Several Python distributions can coexist on a single system.
21+
Several Python distributions can coexist on a system.
2522
If you don't have access to a recent Python version via your
26-
system's package manager (this might be the case for old
27-
Debian or Ubuntu operating systems),
28-
it is recommended to install the latest version of the
23+
system's package manager (may be the case for old systems),
24+
we recommend to install the latest version of the
2925
`Anaconda Python 3 distribution <https://www.continuum.io/downloads>`_.
3026
See also: :ref:`anacondaCluster`.
3127

32-
3328
PIP Installation
3429
----------------
3530

@@ -40,10 +35,8 @@ The package can be installed via pip.::
4035

4136
pip install pyabc
4237

43-
4438
into your system's Python distribution. This requires usually root access.
4539

46-
4740
Install as user into your home directory (recommended)
4841
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4942

@@ -56,20 +49,15 @@ home directory with::
5649

5750
pip install --user pyabc
5851

59-
60-
6152
GIT Installation
6253
----------------
6354

6455
If you want the bleeding edge version, install directly from github::
6556

6657
pip install git+https://github.com/icb-dcm/pyabc.git
6758

68-
69-
7059
.. _upgrading:
7160

72-
7361
Upgrading
7462
---------
7563

@@ -78,61 +66,36 @@ pyABC version, use::
7866

7967
pip install --upgrade pyabc
8068

81-
8269
instead of ``pip install``.
8370
You can also consult the `pip documentation <https://pip.pypa.io/en/stable/>`_
8471
on how to manage packages.
8572
If you installed pyABC into your
8673
home directory with
8774
``pip install --user pyabc``, then upgrade also with the ``--user`` flag::
8875

89-
9076
pip install --upgrade --user pyabc
9177

92-
93-
94-
9578
.. _anacondaCluster:
9679

9780
Installing Anaconda on a Cluster environment
9881
--------------------------------------------
9982

100-
We're assuming you're on a Linux environment.
101-
Use the most recent Anaconda Python 3.x distribution.
102-
As of writing this documentation, this is the
103-
`Anaconda Python 3.6 <https://www.continuum.io/downloads>`_ distribution.
104-
To install it, run::
105-
106-
wget https://repo.continuum.io/archive/Anaconda3-4.4.0-Linux-x86_64.sh
107-
108-
to download the installer. To execute the installer run::
109-
110-
bash Anaconda3-4.4.0-Linux-x86_64.sh
111-
112-
and follow the guided installation process (i.e. approve the license
113-
and tell the installer where to install it to). You might want to replace
114-
the "4.4.0" by the most recent version of Anaconda.
115-
Find out on the `Anaconda Download <https://www.continuum.io/downloads>`_
116-
page which one it is.
117-
118-
119-
.. note::
83+
To install `Anaconda <https://anaconda.com/products/distribution>`_, run::
12084

121-
The Anaconda installer asks you at the end of the installation whether
122-
you want to use Anaconda Python as your default Python:: bash
85+
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
86+
bash Anaconda3-2021.11-Linux-x86_64.sh
12387

124-
Do you wish the installer to prepend the Anaconda3 install location
125-
to PATH in your /home/username/.bashrc ? [yes|no]
126-
[no] >>>
88+
and follow the installation guide.
89+
Replace the "2021.11" by the most recent version of Anaconda, see
90+
https://repo.anaconda.com/archive.
12791

128-
If you answer yes, the path to the Anaconda installation is prepended to
129-
your ``PATH`` environment variable and subsequent calls to ``pip``
130-
(see below) use the Anaconda Python pip (check with the command
131-
``which pip``).
132-
If you answer no, you need to ensure manually, that the correct Python
133-
installation is used.
134-
Just saying "yes" here might safe you from some difficulties later on.
92+
`Miniconda <https://docs.conda.io/en/latest/miniconda.html>`_
93+
provides an alternative, minimal installer for conda, including
94+
only conda, Python, and some core and useful packages. Install the latest
95+
version via::
13596

97+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
98+
bash Miniconda3-latest-Linux-x86_64.sh
13699

137100
.. _install-optional:
138101

pyabc/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
from .random_variables import (
100100
RV,
101101
Distribution,
102+
DistributionBase,
102103
LowerBoundDecorator,
103104
RVBase,
104105
RVDecorator,

pyabc/random_variables.py

+32-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class RVBase(ABC):
2727
distributions are not pickleable.
2828
This class is really a very thin wrapper around ``scipy.stats``
2929
distributions to make them pickleable.
30-
It is important to be able to pickle them to execute the ACBSMC
30+
It is important to be able to pickle them to execute the ABCSMC
3131
algorithm in a distributed cluster
3232
environment
3333
"""
@@ -192,7 +192,7 @@ class RVDecorator(RVBase):
192192
193193
It stores the decorated random variable in ``self.component``
194194
195-
Overwrite the method ``decorator_repr`` the represent the decorator type.
195+
Overwrite the method ``decorator_repr`` to represent the decorator type.
196196
The decorated variable will then be automatically included in
197197
the call to ``__repr__``.
198198
@@ -310,16 +310,42 @@ def cdf(self, x, *args, **kwargs):
310310
return (self.component.cdf(x) - lower_mass) / (1 - lower_mass)
311311

312312

313-
class Distribution(ParameterStructure):
314-
"""Distribution of parameters for a model.
313+
class DistributionBase(ABC):
314+
"""Distribution of parameters for a model, abstract base class.
315315
316316
A distribution is a collection of RVs and/or distributions.
317+
318+
This should be used to define a prior.
319+
"""
320+
321+
@abstractmethod
322+
def rvs(self, *args, **kwargs) -> Parameter:
323+
"""Sample from joint distribution.
324+
325+
Returns
326+
-------
327+
parameter: Parameter
328+
A parameter which was sampled.
329+
"""
330+
331+
@abstractmethod
332+
def pdf(self, x: Union[Parameter, dict]):
333+
"""Get probability density at point `x`.
334+
335+
Parameters
336+
----------
337+
x : Union[Parameter, dict]
338+
Evaluate at the given Parameter ``x``.
339+
"""
340+
341+
342+
class Distribution(DistributionBase, ParameterStructure):
343+
"""Distribution of parameters for a model assuming independence.
344+
317345
Essentially something like a dictionary
318346
of random variables or distributions.
319347
The variables from which the distribution is initialized are
320348
independent.
321-
322-
This should be used to define a prior.
323349
"""
324350

325351
def __repr__(self):
@@ -394,7 +420,6 @@ def rvs(self, *args, **kwargs) -> Parameter:
394420
395421
Returns
396422
-------
397-
398423
parameter: Parameter
399424
A parameter which was sampled.
400425
"""

pyabc/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.12.2'
1+
__version__ = '0.12.3'

test/run_notebooks.sh

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ nbs_2=(
2323
"data_plots"
2424
"discrete_parameters"
2525
"optimal_threshold"
26+
"custom_priors"
2627
)
2728

2829
# All notebooks

0 commit comments

Comments
 (0)