Skip to content

Commit

Permalink
Merge branch 'master' into cover-choose-chains
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Dec 12, 2020
2 parents 6d264f2 + 2a38198 commit 79c7e87
Show file tree
Hide file tree
Showing 21 changed files with 301 additions and 116 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/arviz_compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
TEST_SUBSET: ${{ matrix.test-subset }}
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc.cxxflags='-march=native'
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
defaults:
run:
shell: bash -l {0}
Expand All @@ -33,6 +33,18 @@ jobs:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda-envs/environment-dev-py38.yml') }}
- name: Cache multiple paths
uses: actions/cache@v2
env:
# Increase this value to reset cache if requirements.txt has not changed
CACHE_NUMBER: 0
with:
path: |
~/.cache/pip
$RUNNER_TOOL_CACHE/Python/*
~\AppData\Local\pip\Cache
key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{
hashFiles('requirements.txt') }}
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: pymc3-dev-py38
Expand All @@ -47,7 +59,7 @@ jobs:
- name: Install latest arviz
run: |
conda activate pymc3-dev-py38
conda remove arviz -y
pip uninstall arviz -y
pip install git+git://github.com/arviz-devs/arviz.git
- name: Run tests
run: |
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
--ignore=pymc3/tests/test_examples.py
--ignore=pymc3/tests/test_gp.py
--ignore=pymc3/tests/test_mixture.py
--ignore=pymc3/tests/test_ode.py
--ignore=pymc3/tests/test_parallel_sampling.py
--ignore=pymc3/tests/test_posteriors.py
--ignore=pymc3/tests/test_quadpotential.py
Expand All @@ -43,6 +44,7 @@ jobs:
- |
pymc3/tests/test_examples.py
pymc3/tests/test_mixture.py
pymc3/tests/test_ode.py
pymc3/tests/test_posteriors.py
pymc3/tests/test_quadpotential.py
- |
Expand All @@ -59,7 +61,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
TEST_SUBSET: ${{ matrix.test-subset }}
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc.cxxflags='-march=native'
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
defaults:
run:
shell: bash -l {0}
Expand All @@ -74,6 +76,18 @@ jobs:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda-envs/environment-dev-py36.yml') }}
- name: Cache multiple paths
uses: actions/cache@v2
env:
# Increase this value to reset cache if requirements.txt has not changed
CACHE_NUMBER: 0
with:
path: |
~/.cache/pip
$RUNNER_TOOL_CACHE/Python/*
~\AppData\Local\pip\Cache
key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{
hashFiles('requirements.txt') }}
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: pymc3-dev-py36
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
TEST_SUBSET: ${{ matrix.test-subset }}
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc.cxxflags='-march=core2'
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2'
defaults:
run:
shell: bash -l {0}
Expand All @@ -32,12 +32,29 @@ jobs:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda-envs/environment-dev-py37.yml') }}
- name: Cache multiple paths
uses: actions/cache@v2
env:
# Increase this value to reset cache if requirements.txt has not changed
CACHE_NUMBER: 0
with:
path: |
~/.cache/pip
$RUNNER_TOOL_CACHE/Python/*
~\AppData\Local\pip\Cache
key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{
hashFiles('requirements.txt') }}
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: pymc3-dev-py37
channel-priority: strict
environment-file: conda-envs/environment-dev-py37.yml
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Install-pymc3
run: |
conda activate pymc3-dev-py37
pip install -e .
python --version
- run: |
conda activate pymc3-dev-py37
python -m pytest -vv --cov=pymc3 --cov-report=xml --cov-report term --durations=50 $TEST_SUBSET
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repos:
- id: no-commit-to-branch
args: [--branch, master]
- id: requirements-txt-fixer
exclude: ^requirements-dev\.txt$
- id: trailing-whitespace
- repo: https://github.com/nbQA-dev/nbQA
rev: 0.5.4
Expand Down Expand Up @@ -61,6 +62,19 @@ repos:
language: python
name: Check no tests are ignored
pass_filenames: false
- id: conda-env-sort
additional_dependencies: [pyyaml]
entry: python scripts/sort_conda_envs.py
files: ^conda-envs/
language: python
name: Sort dependencies in conda envs
types: [yaml]
- id: pip-from-conda
additional_dependencies: [pyyaml]
entry: python scripts/generate_pip_deps_from_conda.py
files: ^conda-envs/
language: python
name: Generate pip dependency from conda
- id: no-relative-imports
name: No relative imports
entry: from \.[\.\w]* import
Expand Down
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ We appreciate being notified of problems with the existing PyMC code. We prefer

Please verify that your issue is not being currently addressed by other issues or pull requests by using the GitHub search tool to look for key words in the project issue tracker.

Filter on the ["beginner friendly"](https://github.com/pymc-devs/pymc3/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22) label for issues which are good for new contributors.

# Contributing code via pull requests

While issue reporting is valuable, we strongly encourage users who are inclined to do so to submit patches for new or existing issues via pull requests. This is particularly the case for simple fixes, such as typos or tweaks to documentation, which do not require a heavy investment of time and attention.
Expand All @@ -38,7 +40,7 @@ The preferred workflow for contributing to PyMC3 is to fork the [GitHub reposito
3. Create a ``feature`` branch to hold your development changes:

```bash
$ git switch -c my-feature
$ git checkout -b my-feature
```

Always use a ``feature`` branch. It's good practice to never routinely work on the ``master`` branch of any repository.
Expand Down Expand Up @@ -147,4 +149,6 @@ Follow [TensorFlow's style guide](https://www.tensorflow.org/community/contribut

For documentation strings, we *prefer* [numpy style](https://numpydoc.readthedocs.io/en/latest/format.html) to comply with the style that predominates in our upstream dependencies.

Finally, see the [PyMC3 Python Code Style](https://github.com/pymc-devs/pymc3/wiki/PyMC3-Python-Code-Style) and the [PyMC's Jupyter Notebook Style](https://github.com/pymc-devs/pymc3/wiki/PyMC's-Jupyter-Notebook-Style) guides.

#### This guide was derived from the [scikit-learn guide to contributing](https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md)
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Maintenance
- Fixed bug whereby partial traces returns after keyboard interrupt during parallel sampling had fewer draws than would've been available [#4318](https://github.com/pymc-devs/pymc3/pull/4318)
- Make `sample_shape` same across all contexts in `draw_values` (see [#4305](https://github.com/pymc-devs/pymc3/pull/4305)).

## PyMC3 3.10.0 (7 December 2020)

Expand Down
47 changes: 19 additions & 28 deletions conda-envs/environment-dev-py36.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
name: pymc3-dev-py36
channels:
- conda-forge
- defaults
- conda-forge
- defaults
dependencies:
- python=3.6
- arviz>=0.9
- theano-pymc==1.0.11
- numpy>=1.13
- scipy>=0.18
- pandas>=0.18
- patsy>=0.5
- fastprogress>=0.2
- h5py>=2.7
- typing-extensions>=3.7
- python-graphviz
- ipython>=7.16
- nbsphinx>=0.4
- numpydoc>=0.9
- pre-commit>=2.8.0
- pytest-cov>=2.5
- pytest>=3.0
- recommonmark>=0.4
- sphinx-autobuild>=0.7
- sphinx>=1.5
- watermark
- dataclasses # python_version < 3.7
- contextvars # python_version < 3.7
- mkl-service
- dill
- libblas=*=*mkl
- contextvars
- dataclasses
- h5py>=2.7
- ipython>=7.16
- libblas=*=*mkl
- mkl-service
- nbsphinx>=0.4
- numpydoc>=0.9
- pre-commit>=2.8.0
- pytest-cov>=2.5
- pytest>=3.0
- python-graphviz
- python=3.6
- recommonmark>=0.4
- sphinx-autobuild>=0.7
- sphinx>=1.5
- watermark
43 changes: 17 additions & 26 deletions conda-envs/environment-dev-py37.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
name: pymc3-dev-py37
channels:
- conda-forge
- defaults
- conda-forge
- defaults
dependencies:
- python=3.7
- arviz>=0.9
- theano-pymc==1.0.11
- numpy>=1.13
- scipy>=0.18
- pandas>=0.18
- patsy>=0.5
- fastprogress>=0.2
- h5py>=2.7
- typing-extensions>=3.7
- python-graphviz
- ipython>=7.16
- nbsphinx>=0.4
- numpydoc>=0.9
- pre-commit>=2.8.0
- pytest-cov>=2.5
- pytest>=3.0
- recommonmark>=0.4
- sphinx-autobuild>=0.7
- sphinx>=1.5
- watermark
- mkl-service
- dill
- libblas=*=*mkl
- h5py>=2.7
- ipython>=7.16
- libblas=*=*mkl
- mkl-service
- nbsphinx>=0.4
- numpydoc>=0.9
- pre-commit>=2.8.0
- pytest-cov>=2.5
- pytest>=3.0
- python-graphviz
- python=3.7
- recommonmark>=0.4
- sphinx-autobuild>=0.7
- sphinx>=1.5
- watermark
43 changes: 17 additions & 26 deletions conda-envs/environment-dev-py38.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
name: pymc3-dev-py38
channels:
- conda-forge
- defaults
- conda-forge
- defaults
dependencies:
- python=3.8
- arviz>=0.9
- theano-pymc==1.0.11
- numpy>=1.13
- scipy>=0.18
- pandas>=0.18
- patsy>=0.5
- fastprogress>=0.2
- h5py>=2.7
- typing-extensions>=3.7
- python-graphviz
- ipython>=7.16
- nbsphinx>=0.4
- numpydoc>=0.9
- pre-commit>=2.8.0
- pytest-cov>=2.5
- pytest>=3.0
- recommonmark>=0.4
- sphinx-autobuild>=0.7
- sphinx>=1.5
- watermark
- mkl-service
- dill
- libblas=*=*mkl
- h5py>=2.7
- ipython>=7.16
- libblas=*=*mkl
- mkl-service
- nbsphinx>=0.4
- numpydoc>=0.9
- pre-commit>=2.8.0
- pytest-cov>=2.5
- pytest>=3.0
- python-graphviz
- python=3.8
- recommonmark>=0.4
- sphinx-autobuild>=0.7
- sphinx>=1.5
- watermark
4 changes: 2 additions & 2 deletions pymc3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __set_compiler_flags():
# Workarounds for Theano compiler problems on various platforms
import theano

current = theano.config.gcc.cxxflags
theano.config.gcc.cxxflags = f"{current} -Wno-c++11-narrowing"
current = theano.config.gcc__cxxflags
theano.config.gcc__cxxflags = f"{current} -Wno-c++11-narrowing"


__set_compiler_flags()
Expand Down
1 change: 1 addition & 0 deletions pymc3/distributions/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ def draw_values(params, point=None, size=None):
"""
# The following check intercepts and redirects calls to
# draw_values in the context of sample_posterior_predictive
size = to_tuple(size)
ppc_sampler = vectorized_ppc.get(None)
if ppc_sampler is not None:
# this is being done inside new, vectorized sample_posterior_predictive
Expand Down
2 changes: 1 addition & 1 deletion pymc3/distributions/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def perform(self, node, inputs, outputs):
pm._log.exception("Failed to check if %s positive definite", x)
raise

def infer_shape(self, node, shapes):
def infer_shape(self, fgraph, node, shapes):
return [[]]

def grad(self, inp, grads):
Expand Down
7 changes: 4 additions & 3 deletions pymc3/distributions/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from scipy.spatial import cKDTree

from pymc3.distributions.distribution import NoDistribution, draw_values
from pymc3.distributions.distribution import NoDistribution, draw_values, to_tuple

__all__ = ["Simulator"]

Expand Down Expand Up @@ -114,11 +114,12 @@ def random(self, point=None, size=None):
-------
array
"""
size = to_tuple(size)
params = draw_values([*self.params], point=point, size=size)
if size is None:
if len(size) == 0:
return self.function(*params)
else:
return np.array([self.function(*params) for _ in range(size)])
return np.array([self.function(*params) for _ in range(size[0])])

def _str_repr(self, name=None, dist=None, formatting="plain"):
if dist is None:
Expand Down
4 changes: 2 additions & 2 deletions pymc3/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def grad(self, inputs, gout):
idx = tt.arange(gz.shape[-1])
return [gz[..., idx, idx]]

def infer_shape(self, nodes, shapes):
def infer_shape(self, fgraph, nodes, shapes):
return [(shapes[0][0],) + (shapes[0][1],) * 2]


Expand Down Expand Up @@ -422,7 +422,7 @@ def grad(self, inputs, gout):
]
return [gout[0][slc] for slc in slices]

def infer_shape(self, nodes, shapes):
def infer_shape(self, fgraph, nodes, shapes):
first, second = zip(*shapes)
return [(tt.add(*first), tt.add(*second))]

Expand Down
Loading

0 comments on commit 79c7e87

Please sign in to comment.