Skip to content

Commit 9cf211a

Browse files
committed
Merge remote-tracking branch 'upstream/master' into extend-plot_posterior_predictive_glm
2 parents 2ceaa13 + 2723b6c commit 9cf211a

18 files changed

+218
-142
lines changed

.codecov.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
codecov:
2-
require_ci_to_pass: yes
2+
require_ci_to_pass: no
3+
notify:
4+
after_n_builds: 7
35

46
coverage:
57
precision: 2
68
round: down
79
range: "70...100"
8-
910
status:
10-
project: yes
11-
patch: yes
12-
changes: no
11+
project:
12+
default:
13+
# basic
14+
target: auto
15+
threshold: 1%
16+
base: auto
17+
patch:
18+
default:
19+
# basic
20+
target: 50%
21+
threshold: 1%
22+
base: auto
1323

1424
comment:
1525
layout: "reach, diff, flags, files"

.github/workflows/pytest.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: pytest
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
jobs:
9+
pytest:
10+
strategy:
11+
matrix:
12+
python-version: ["3.6"]
13+
os: [ubuntu-18.04]
14+
floatx: [float32, float64]
15+
test-subset:
16+
- |
17+
--ignore=pymc3/tests/test_examples.py
18+
--ignore=pymc3/tests/test_distributions_random.py
19+
--ignore=pymc3/tests/test_variational_inference.py
20+
--ignore=pymc3/tests/test_shared.py
21+
--ignore=pymc3/tests/test_smc.py
22+
--ignore=pymc3/tests/test_updates.py
23+
--ignore=pymc3/tests/test_posteriors.py
24+
--ignore=pymc3/tests/test_sampling.py
25+
--ignore=pymc3/tests/test_parallel_sampling.py
26+
--ignore=pymc3/tests/test_dist_math.py
27+
--ignore=pymc3/tests/test_distribution_defaults.py
28+
--ignore=pymc3/tests/test_distributions_timeseries.py
29+
--ignore=pymc3/tests/test_random.py
30+
--ignore=pymc3/tests/test_gp.py
31+
--ignore=pymc3/tests/test_shape_handling
32+
--ignore=pymc3/tests/test_quadpotential.py
33+
- |
34+
pymc3/tests/test_distributions_random.py
35+
pymc3/tests/test_shared.py
36+
pymc3/tests/test_smc.py
37+
pymc3/tests/test_sampling.py
38+
pymc3/tests/test_parallel_sampling.py
39+
pymc3/tests/test_dist_math.py
40+
pymc3/tests/test_distribution_defaults.py
41+
pymc3/tests/test_distributions_timeseries.py
42+
pymc3/tests/test_random.py
43+
- |
44+
pymc3/tests/test_examples.py
45+
pymc3/tests/test_posteriors.py
46+
pymc3/tests/test_gp.py
47+
pymc3/tests/test_quadpotential.py
48+
- |
49+
pymc3/tests/test_variational_inference.py
50+
pymc3/tests/test_updates.py
51+
pymc3/tests/test_shape_handling.py
52+
runs-on: ${{ matrix.os }}
53+
env:
54+
TEST_SUBSET: ${{ matrix.test-subset }}
55+
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc.cxxflags='-march=native'
56+
defaults:
57+
run:
58+
shell: bash -l {0}
59+
steps:
60+
- uses: actions/checkout@v2
61+
- name: Cache conda
62+
uses: actions/cache@v1
63+
env:
64+
# Increase this value to reset cache if environment-dev.yml has not changed
65+
CACHE_NUMBER: 0
66+
with:
67+
path: ~/conda_pkgs_dir
68+
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
69+
hashFiles('environment-dev.yml') }}
70+
- uses: conda-incubator/setup-miniconda@v2
71+
with:
72+
activate-environment: testenv
73+
channel-priority: strict
74+
environment-file: environment-dev.yml
75+
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
76+
- run: |
77+
conda activate testenv
78+
python -m pytest -v --cov=pymc3 --cov-report=xml --cov-report term --durations=50 $TEST_SUBSET -n auto
79+
- name: Upload coverage to Codecov
80+
uses: codecov/codecov-action@v1
81+
with:
82+
env_vars: OS,PYTHON
83+
name: codecov-umbrella
84+
fail_ci_if_error: false

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ repos:
2222
rev: 20.8b1
2323
hooks:
2424
- id: black
25+
- repo: https://github.com/PyCQA/pylint
26+
rev: pylint-2.6.0
27+
hooks:
28+
- id: pylint
29+
args: [--rcfile=.pylintrc]
30+
files: ^pymc3/
2531
- repo: local
2632
hooks:
2733
- id: watermark

.pylintrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ disable=all
3434
# Enable the message, report, category or checker with the given id(s). You can
3535
# either give multiple identifier separated by comma (,) or put this option
3636
# multiple time. See also the "--disable" option for examples.
37-
enable=import-error,
38-
import-self,
37+
enable=import-self,
3938
reimported,
4039
wildcard-import,
4140
misplaced-future,

.travis.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Features
3939
- **Variational inference**: `ADVI <http://www.jmlr.org/papers/v18/16-107.html>`__
4040
for fast approximate posterior estimation as well as mini-batch ADVI
4141
for large data sets.
42-
- Relies on `Theano <http://deeplearning.net/software/theano/>`__ which provides:
42+
- Relies on `Theano <https://theano-pymc.readthedocs.io/en/latest/>`__ which provides:
4343
* Computation optimization and dynamic C compilation
4444
* Numpy broadcasting and advanced indexing
4545
* Linear algebra operators

RELEASE-NOTES.md

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,55 @@
11
# Release Notes
22

3-
## PyMC3 3.9.x (on deck)
3+
## PyMC3 3.10.0 (on deck)
44

5-
### Maintenance
6-
- Removed non-NDArray (Text, SQLite, HDF5) backends and associated tests.
7-
- Switch the dependency of Theano to our own fork, [Theano-PyMC](https://github.com/pymc-devs/Theano-PyMC).
8-
- Mentioned the way to do any random walk with `theano.tensor.cumsum()` in `GaussianRandomWalk` docstrings (see [#4048](https://github.com/pymc-devs/pymc3/pull/4048)).
9-
- Fixed numerical instability in ExGaussian's logp by preventing `logpow` from returning `-inf` (see [#4050](https://github.com/pymc-devs/pymc3/pull/4050)).
10-
- Use dill to serialize user defined logp functions in `DensityDist`. The previous serialization code fails if it is used in notebooks on Windows and Mac. `dill` is now a required dependency. (see [#3844](https://github.com/pymc-devs/pymc3/issues/3844)).
11-
- Numerically improved stickbreaking transformation - e.g. for the `Dirichlet` distribution. [#4129](https://github.com/pymc-devs/pymc3/pull/4129)
12-
- Enabled the `Multinomial` distribution to handle batch sizes that have more than 2 dimensions. [#4169](https://github.com/pymc-devs/pymc3/pull/4169)
5+
This is a major release with many exciting new features. The biggest change is that we now rely on our own fork of [Theano-PyMC](https://github.com/pymc-devs/Theano-PyMC). This is in line with our [big announcement about our commitment to PyMC3 and Theano](https://pymc-devs.medium.com/the-future-of-pymc3-or-theano-is-dead-long-live-theano-d8005f8a0e9b).
136

14-
### Documentation
7+
When upgrading, make sure that `Theano-PyMC` and not `Theano` are installed (the imports remain unchanged, however). If not, you can uninstall `Theano`:
8+
```
9+
conda remove theano
10+
```
11+
12+
And to install:
13+
```
14+
conda install -c conda-forge theano-pymc
15+
```
16+
17+
Or, if you are using pip (not recommended):
18+
```
19+
pip uninstall theano
20+
```
21+
And to install:
22+
```
23+
pip install theano-pymc
24+
```
1525

16-
* Added a new notebook demonstrating how to incorporate sampling from a conjugate Dirichlet-multinomial posterior density in conjunction with other step methods (see [#4199](https://github.com/pymc-devs/pymc3/pull/4199)).
26+
This new version of `Theano-PyMC` comes with an experimental JAX backend which, when combined with the new and experimental JAX samplers in PyMC3, can greatly speed up sampling in your model. As this is still very new, please do not use it in production yet but do test it out and let us know if anything breaks and what results you are seeing, especially speed-wise.
1727

1828
### New features
19-
- `sample_posterior_predictive_w` can now feed on `xarray.Dataset` - e.g. from `InferenceData.posterior`. (see [#4042](https://github.com/pymc-devs/pymc3/pull/4042))
20-
- Added `pymc3.gp.cov.Circular` kernel for Gaussian Processes on circular domains, e.g. the unit circle (see [#4082](https://github.com/pymc-devs/pymc3/pull/4082)).
2129
- Add MLDA, a new stepper for multilevel sampling. MLDA can be used when a hierarchy of approximate posteriors of varying accuracy is available, offering improved sampling efficiency especially in high-dimensional problems and/or where gradients are not available (see [#3926](https://github.com/pymc-devs/pymc3/pull/3926))
30+
- Add Bayesian Additive Regression Trees (BARTs) [#4183](https://github.com/pymc-devs/pymc3/pull/4183))
31+
- Added `pymc3.gp.cov.Circular` kernel for Gaussian Processes on circular domains, e.g. the unit circle (see [#4082](https://github.com/pymc-devs/pymc3/pull/4082)).
32+
- Added a new `MixtureSameFamily` distribution to handle mixtures of arbitrary dimensions in vectorized form for improved speed (see [#4185](https://github.com/pymc-devs/pymc3/issues/4185)).
33+
- `sample_posterior_predictive_w` can now feed on `xarray.Dataset` - e.g. from `InferenceData.posterior`. (see [#4042](https://github.com/pymc-devs/pymc3/pull/4042))
2234
- Change SMC metropolis kernel to independent metropolis kernel [#4115](https://github.com/pymc-devs/pymc3/pull/4115))
2335
- Add alternative parametrization to NegativeBinomial distribution in terms of n and p (see [#4126](https://github.com/pymc-devs/pymc3/issues/4126))
24-
- Add Bayesian Additive Regression Trees (BARTs) [#4183](https://github.com/pymc-devs/pymc3/pull/4183))
25-
- Added a new `MixtureSameFamily` distribution to handle mixtures of arbitrary dimensions in vectorized form (see [#4185](https://github.com/pymc-devs/pymc3/issues/4185)).
26-
- Added semantically meaningful `str` representations to PyMC3 objects for console, notebook, and GraphViz use (see [#4076](https://github.com/pymc-devs/pymc3/pull/4076), [#4065](https://github.com/pymc-devs/pymc3/pull/4065), [#4159](https://github.com/pymc-devs/pymc3/pull/4159), and [#4217](https://github.com/pymc-devs/pymc3/pull/4217))
36+
- Added semantically meaningful `str` representations to PyMC3 objects for console, notebook, and GraphViz use (see [#4076](https://github.com/pymc-devs/pymc3/pull/4076), [#4065](https://github.com/pymc-devs/pymc3/pull/4065), [#4159](https://github.com/pymc-devs/pymc3/pull/4159), [#4217](https://github.com/pymc-devs/pymc3/pull/4217), and [#4243](https://github.com/pymc-devs/pymc3/pull/4243)).
2737
- `plot_posterior_predictive_glm` now works with `arviz.InferenceData` as well (see [#4234](https://github.com/pymc-devs/pymc3/pull/4234))
2838

29-
30-
31-
## PyMC3 3.9.3 (11 August 2020)
32-
3339
### Maintenance
34-
- Fix an error on Windows and Mac where error message from unpickling models did not show up in the notebook, or where sampling froze when a worker process crashed (see [#3991](https://github.com/pymc-devs/pymc3/pull/3991)).
35-
- Require Theano >= 1.0.5 (see [#4032](https://github.com/pymc-devs/pymc3/pull/4032)).
40+
- Switch the dependency of Theano to our own fork, [Theano-PyMC](https://github.com/pymc-devs/Theano-PyMC).
41+
- Removed non-NDArray (Text, SQLite, HDF5) backends and associated tests.
42+
- Use dill to serialize user defined logp functions in `DensityDist`. The previous serialization code fails if it is used in notebooks on Windows and Mac. `dill` is now a required dependency. (see [#3844](https://github.com/pymc-devs/pymc3/issues/3844)).
43+
- Fixed numerical instability in ExGaussian's logp by preventing `logpow` from returning `-inf` (see [#4050](https://github.com/pymc-devs/pymc3/pull/4050)).
44+
- Numerically improved stickbreaking transformation - e.g. for the `Dirichlet` distribution. [#4129](https://github.com/pymc-devs/pymc3/pull/4129)
45+
- Enabled the `Multinomial` distribution to handle batch sizes that have more than 2 dimensions. [#4169](https://github.com/pymc-devs/pymc3/pull/4169)
3646

3747
### Documentation
38-
- Notebook on [multilevel modeling](https://docs.pymc.io/notebooks/multilevel_modeling.html) has been rewritten to showcase ArviZ and xarray usage for inference result analysis (see [#3963](https://github.com/pymc-devs/pymc3/pull/3963)).
48+
- Added a new notebook demonstrating how to incorporate sampling from a conjugate Dirichlet-multinomial posterior density in conjunction with other step methods (see [#4199](https://github.com/pymc-devs/pymc3/pull/4199)).
49+
- Mentioned the way to do any random walk with `theano.tensor.cumsum()` in `GaussianRandomWalk` docstrings (see [#4048](https://github.com/pymc-devs/pymc3/pull/4048)).
50+
51+
52+
## PyMC3 3.9.3 (11 August 2020)
3953

4054
### New features
4155
- Introduce optional arguments to `pm.sample`: `mp_ctx` to control how the processes for parallel sampling are started, and `pickle_backend` to specify which library is used to pickle models in parallel sampling when the multiprocessing context is not of type `fork` (see [#3991](https://github.com/pymc-devs/pymc3/pull/3991)).
@@ -44,10 +58,18 @@
4458
- SMC-ABC: add the Wasserstein and energy distance functions. Refactor API, the distance, sum_stats and epsilon arguments are now passed `pm.Simulator` instead of `pm.sample_smc`. Add random method to `pm.Simulator`. Add option to save the simulated data. Improved LaTeX representation [#3996](https://github.com/pymc-devs/pymc3/pull/3996).
4559
- SMC-ABC: Allow use of potentials by adding them to the prior term. [#4016](https://github.com/pymc-devs/pymc3/pull/4016).
4660

61+
### Maintenance
62+
- Fix an error on Windows and Mac where error message from unpickling models did not show up in the notebook, or where sampling froze when a worker process crashed (see [#3991](https://github.com/pymc-devs/pymc3/pull/3991)).
63+
- Require Theano >= 1.0.5 (see [#4032](https://github.com/pymc-devs/pymc3/pull/4032)).
64+
65+
### Documentation
66+
- Notebook on [multilevel modeling](https://docs.pymc.io/notebooks/multilevel_modeling.html) has been rewritten to showcase ArviZ and xarray usage for inference result analysis (see [#3963](https://github.com/pymc-devs/pymc3/pull/3963)).
67+
4768
_NB: The `docs/*` folder is still removed from the tarball due to an upload size limit on PyPi._
4869

4970

5071
## PyMC3 3.9.2 (24 June 2020)
72+
5173
### Maintenance
5274
- Warning added in GP module when `input_dim` is lower than the number of columns in `X` to compute the covariance function (see [#3974](https://github.com/pymc-devs/pymc3/pull/3974)).
5375
- Pass the `tune` argument from `sample` when using `advi+adapt_diag_grad` (see issue [#3965](https://github.com/pymc-devs/pymc3/issues/3965), fixed by [#3979](https://github.com/pymc-devs/pymc3/pull/3979)).

environment-dev.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
- defaults
55
dependencies:
6-
- python=3.6
6+
- python>=3.6
77
- arviz>=0.9
88
- theano-pymc==1.0.11
99
- numpy>=1.13
@@ -22,23 +22,18 @@ dependencies:
2222
- nose-parameterized>=0.6
2323
- numpydoc>=0.9
2424
- pre-commit>=2.8.0
25-
- pycodestyle>=2.3
26-
- pyflakes>=1.5
27-
- pylint>=1.7
2825
- pytest-cov>=2.5
2926
- pytest>=3.0
27+
- pytest-xdist
3028
- recommonmark>=0.4
3129
- seaborn>=0.8
3230
- sphinx-autobuild>=0.7
3331
- sphinx>=1.5
3432
- watermark
3533
- parameterized
36-
- black
3734
- ipywidgets
3835
- dataclasses # python_version < 3.7
3936
- contextvars # python_version < 3.7
4037
- mkl-service
4138
- dill
4239
- libblas=*=*mkl
43-
- pip:
44-
- black_nbconvert

pymc3/backends/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
"""
1919
import itertools as itl
2020
import logging
21-
from typing import Dict, List, Optional
21+
from typing import List
2222
from abc import ABC
2323

2424
import numpy as np
2525
import warnings
2626
import theano.tensor as tt
2727

28-
from ..model import modelcontext, Model
28+
from ..model import modelcontext
2929
from .report import SamplerReport, merge_reports
3030
from ..util import get_var_name
3131

pymc3/distributions/distribution.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ def _str_repr(self, name=None, dist=None, formatting="plain"):
194194
)
195195

196196
def __str__(self, **kwargs):
197-
return self._str_repr(formatting="plain", **kwargs)
197+
try:
198+
return self._str_repr(formatting="plain", **kwargs)
199+
except:
200+
return super().__str__()
198201

199202
def _repr_latex_(self, **kwargs):
200203
"""Magic method name for IPython to use for LaTeX formatting."""

0 commit comments

Comments
 (0)