Skip to content

Commit 21bf324

Browse files
Merge branch 'fix-4206' of https://github.com/michaelosthege/pymc3 into fix-4206
2 parents b81397e + fac09f8 commit 21bf324

17 files changed

+249
-133
lines changed

.codecov.yml

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

46
coverage:
57
precision: 2

.github/workflows/arviz_compat.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: arviz-compatibility
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
jobs:
9+
pytest:
10+
strategy:
11+
matrix:
12+
python-version: ["3.8"]
13+
os: [ubuntu-18.04]
14+
floatx: [float64]
15+
test-subset:
16+
- pymc3/tests/test_sampling.py
17+
runs-on: ${{ matrix.os }}
18+
env:
19+
TEST_SUBSET: ${{ matrix.test-subset }}
20+
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc.cxxflags='-march=native'
21+
defaults:
22+
run:
23+
shell: bash -l {0}
24+
steps:
25+
- uses: actions/checkout@v2
26+
- name: Cache conda
27+
uses: actions/cache@v1
28+
env:
29+
# Increase this value to reset cache if environment-dev.yml has not changed
30+
CACHE_NUMBER: 0
31+
with:
32+
path: ~/conda_pkgs_dir
33+
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
34+
hashFiles('environment-dev.yml') }}
35+
- uses: conda-incubator/setup-miniconda@v2
36+
with:
37+
activate-environment: testenv
38+
channel-priority: strict
39+
environment-file: environment-dev.yml
40+
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
41+
- run: |
42+
conda activate testenv
43+
conda remove arviz -y
44+
pip install git+git://github.com/arviz-devs/arviz.git
45+
python -m pytest -v --cov=pymc3 --cov-report=xml --cov-report term --durations=50 $TEST_SUBSET -n auto

.github/workflows/pytest.yml

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

RELEASE-NOTES.md

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,54 @@
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))
27-
28-
29-
30-
## PyMC3 3.9.3 (11 August 2020)
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)).
3137

3238
### Maintenance
33-
- 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)).
34-
- Require Theano >= 1.0.5 (see [#4032](https://github.com/pymc-devs/pymc3/pull/4032)).
39+
- Switch the dependency of Theano to our own fork, [Theano-PyMC](https://github.com/pymc-devs/Theano-PyMC).
40+
- Removed non-NDArray (Text, SQLite, HDF5) backends and associated tests.
41+
- 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)).
42+
- Fixed numerical instability in ExGaussian's logp by preventing `logpow` from returning `-inf` (see [#4050](https://github.com/pymc-devs/pymc3/pull/4050)).
43+
- Numerically improved stickbreaking transformation - e.g. for the `Dirichlet` distribution. [#4129](https://github.com/pymc-devs/pymc3/pull/4129)
44+
- Enabled the `Multinomial` distribution to handle batch sizes that have more than 2 dimensions. [#4169](https://github.com/pymc-devs/pymc3/pull/4169)
3545

3646
### Documentation
37-
- 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)).
47+
- 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)).
48+
- 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)).
49+
50+
51+
## PyMC3 3.9.3 (11 August 2020)
3852

3953
### New features
4054
- 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)).
@@ -43,10 +57,18 @@
4357
- 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).
4458
- SMC-ABC: Allow use of potentials by adding them to the prior term. [#4016](https://github.com/pymc-devs/pymc3/pull/4016).
4559

60+
### Maintenance
61+
- 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)).
62+
- Require Theano >= 1.0.5 (see [#4032](https://github.com/pymc-devs/pymc3/pull/4032)).
63+
64+
### Documentation
65+
- 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)).
66+
4667
_NB: The `docs/*` folder is still removed from the tarball due to an upload size limit on PyPi._
4768

4869

4970
## PyMC3 3.9.2 (24 June 2020)
71+
5072
### Maintenance
5173
- 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)).
5274
- 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

0 commit comments

Comments
 (0)