Skip to content

Commit 39d95eb

Browse files
authored
Merge pull request #62 from pymc-devs/master
Sync Fork from Upstream Repo
2 parents ed0dd35 + f4489a3 commit 39d95eb

File tree

11 files changed

+134
-22
lines changed

11 files changed

+134
-22
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ repos:
1414
exclude: ^requirements-dev\.txt$
1515
- id: trailing-whitespace
1616
- repo: https://github.com/PyCQA/isort
17-
rev: 5.7.0
17+
rev: 5.8.0
1818
hooks:
1919
- id: isort
2020
name: isort
2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v2.10.0
22+
rev: v2.11.0
2323
hooks:
2424
- id: pyupgrade
2525
args: [--py37-plus]

README.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:alt: PyMC3 logo
44
:align: center
55

6-
|Build Status| |Coverage| |NumFOCUS_badge| |Binder| |Dockerhub|
6+
|Build Status| |Coverage| |NumFOCUS_badge| |Binder| |Dockerhub| |DOIzenodo|
77

88
PyMC3 is a Python package for Bayesian statistical modeling and Probabilistic Machine Learning
99
focusing on advanced Markov chain Monte Carlo (MCMC) and variational inference (VI)
@@ -74,10 +74,16 @@ To install PyMC3 on your system, follow the instructions on the appropriate inst
7474

7575
Citing PyMC3
7676
============
77+
Please choose from the following:
7778

78-
Salvatier J., Wiecki T.V., Fonnesbeck C. (2016) Probabilistic programming
79-
in Python using PyMC3. PeerJ Computer Science 2:e55
80-
`DOI: 10.7717/peerj-cs.55 <https://doi.org/10.7717/peerj-cs.55>`__.
79+
- |DOIpaper| *Probabilistic programming in Python using PyMC3*, Salvatier J., Wiecki T.V., Fonnesbeck C. (2016)
80+
- |DOIzenodo| A DOI for all versions.
81+
- DOIs for specific versions are shown on Zenodo and under `Releases <https://github.com/pymc-devs/pymc3/releases>`_
82+
83+
.. |DOIpaper| image:: https://img.shields.io/badge/DOI-10.7717%2Fpeerj--cs.55-blue
84+
:target: https://doi.org/10.7717/peerj-cs.55
85+
.. |DOIzenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.4603970.svg
86+
:target: https://doi.org/10.5281/zenodo.4603970
8187

8288
Contact
8389
=======

RELEASE-NOTES.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## PyMC3 vNext (4.0.0)
44
### Breaking Changes
55
- ⚠ Theano-PyMC has been replaced with Aesara, so all external references to `theano`, `tt`, and `pymc3.theanof` need to be replaced with `aesara`, `aet`, and `pymc3.aesaraf` (see [4471](https://github.com/pymc-devs/pymc3/pull/4471)).
6+
- ArviZ `plots` and `stats` *wrappers* were removed. The functions are now just available by their original names (see [#4549](https://github.com/pymc-devs/pymc3/pull/4471) and `3.11.2` release notes).
7+
- ...
68

79
### New Features
810
- The `CAR` distribution has been added to allow for use of conditional autoregressions which often are used in spatial and network models.

docs/source/api/plots.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Plots
77
Plots are delegated to the
88
`ArviZ <https://arviz-devs.github.io/arviz/index.html>`_.
99
library, a general purpose library for
10-
"exploratory analysis of Bayesian models."
11-
Refer to its documentation to use the plotting functions directly.
10+
"exploratory analysis of Bayesian models".
1211

13-
.. automodule:: pymc3.plots.posteriorplot
14-
:members:
12+
Functions from the `arviz.plots` module are available through ``pymc3.<function>`` or ``pymc3.plots.<function>``,
13+
but for their API documentation please refer to the :ref:`ArviZ documentation <arviz:plot_api>`.

docs/source/api/stats.rst

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
*****
22
Stats
33
*****
4+
5+
.. currentmodule:: pymc3.stats
6+
47
Statistics and diagnostics are delegated to the
58
`ArviZ <https://arviz-devs.github.io/arviz/index.html>`_.
69
library, a general purpose library for
7-
"exploratory analysis of Bayesian models."
8-
Refer to its documentation to use the diagnostics functions directly.
10+
"exploratory analysis of Bayesian models".
11+
12+
Functions from the `arviz.stats` module are available through ``pymc3.<function>`` or ``pymc3.stats.<function>``,
13+
but for their API documentation please refer to the :ref:`ArviZ documentation <arviz:stats_api>`.

docs/source/index.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,12 @@
115115

116116
<div class="ui vertical segment">
117117
<h2 class="ui dividing header">Citing PyMC3</h2>
118-
<p>Salvatier J., Wiecki T.V., Fonnesbeck C. (2016) Probabilistic programming in Python using PyMC3. PeerJ
119-
Computer Science 2:e55 <a href="https://doi.org/10.7717/peerj-cs.55">DOI: 10.7717/peerj-cs.55</a>.</p>
118+
<p>Please choose from the following:</p>
119+
<ul>
120+
<li><a href="https://doi.org/10.7717/peerj-cs.55" rel="nofollow"><img alt="DOIpaper" src="https://camo.githubusercontent.com/6a7e1c555ea828c2f9253f7cff0868debe9fdc711694424b913bf95f6d2da9dd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f444f492d31302e37373137253246706565726a2d2d63732e35352d626c7565" data-canonical-src="https://img.shields.io/badge/DOI-10.7717%2Fpeerj--cs.55-blue" style="max-width:100%;"></a> <em>Probabilistic programming in Python using PyMC3</em>, Salvatier J., Wiecki T.V., Fonnesbeck C. (2016)</li>
121+
<li><a href="https://doi.org/10.5281/zenodo.4603970" rel="nofollow"><img alt="DOIzenodo" src="https://camo.githubusercontent.com/2b33f91dc16d9e7ad37aede0119d197776fbef41b8080c7e38a3629df3d9c201/68747470733a2f2f7a656e6f646f2e6f72672f62616467652f444f492f31302e353238312f7a656e6f646f2e343630333937302e737667" data-canonical-src="https://zenodo.org/badge/DOI/10.5281/zenodo.4603970.svg" style="max-width:100%;"></a> A DOI for all versions.</li>
122+
<li>DOIs for specific versions are shown on Zenodo and under <a href="https://github.com/pymc-devs/pymc3/releases">Releases</a></li>
123+
</ul>
120124
<p>See <a href="https://scholar.google.de/scholar?oi=bibs&hl=en&authuser=1&cites=6936955228135731011">Google Scholar</a> for a continuously updated list of papers citing PyMC3.</p>
121125
</div>
122126

pymc3/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __set_compiler_flags():
6262
from pymc3.plots import *
6363
from pymc3.sampling import *
6464
from pymc3.smc import *
65+
from pymc3.stats import *
6566
from pymc3.step_methods import *
6667
from pymc3.tests import test
6768
from pymc3.tuning import *

pymc3/distributions/continuous.py

+22
Original file line numberDiff line numberDiff line change
@@ -4223,6 +4223,28 @@ class Interpolated(BoundedContinuous):
42234223
Both parameters ``x_points`` and values ``pdf_points`` are not variables, but
42244224
plain array-like objects, so they are constant and cannot be sampled.
42254225
4226+
.. plot::
4227+
4228+
import matplotlib.pyplot as plt
4229+
import numpy as np
4230+
import pymc3 as pm
4231+
import arviz as az
4232+
from scipy.stats import gamma
4233+
plt.style.use('arviz-darkgrid')
4234+
rv = gamma(1.99)
4235+
x = np.linspace(rv.ppf(0.01),rv.ppf(0.99), 1000)
4236+
points = np.linspace(x[0], x[-1], 50)
4237+
pdf = rv.pdf(points)
4238+
interpolated = pm.Interpolated.dist(points, pdf)
4239+
fig, ax = plt.subplots(1, 1)
4240+
ax.plot(x, rv.pdf(x), 'C0', linestyle = '--', label='Original Gamma pdf',alpha=0.8,lw=2)
4241+
ax.plot(points, pdf, color='black', marker='o', label='Lattice Points',alpha=0.5,linestyle='')
4242+
ax.plot(x, np.exp(interpolated.logp(x).eval()),'C1',label='Interpolated pdf',alpha=0.8,lw=3)
4243+
r = interpolated.random(size=1000)
4244+
ax.hist(r, density=True, alpha=0.4,align ='mid',color='grey')
4245+
ax.legend(loc='best', frameon=False)
4246+
plt.show()
4247+
42264248
======== ===========================================
42274249
Support :math:`x \in [x\_points[0], x\_points[-1]]`
42284250
======== ===========================================

pymc3/distributions/posterior_predictive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def __init__(self, vars, trace: _TraceDict, samples, model: Model | None, size=N
342342
self.size = size
343343
self.logger = logging.getLogger("posterior_predictive")
344344

345-
def __enter__(self) -> "_PosteriorPredictiveSampler":
345+
def __enter__(self) -> _PosteriorPredictiveSampler:
346346
self._tok = vectorized_ppc.set(posterior_predictive_draw_values)
347347
return self
348348

pymc3/plots/__init__.py

+49-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020 The PyMC Developers
1+
# Copyright 2021 The PyMC Developers
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,19 +12,61 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""PyMC3 Plotting.
15+
"""Alias for the `plots` submodule from ArviZ.
1616
17-
Plots are delegated to the `ArviZ <https://arviz-devs.github.io/arviz/>`_ library, a general purpose library for
18-
exploratory analysis of Bayesian models. For more details, see https://arviz-devs.github.io/arviz/.
19-
20-
Only `plot_posterior_predictive_glm` is kept in the PyMC code base for now, but it will move to ArviZ once the latter adds features for regression plots.
17+
Plots are delegated to the ArviZ library, a general purpose library for
18+
"exploratory analysis of Bayesian models."
19+
See https://arviz-devs.github.io/arviz/ for details on plots.
2120
"""
2221
import functools
2322
import sys
2423
import warnings
2524

2625
import arviz as az
2726

27+
# Makes this module as identical to arviz.plots as possible
28+
for attr in az.plots.__all__:
29+
obj = getattr(az.plots, attr)
30+
if not attr.startswith("__"):
31+
setattr(sys.modules[__name__], attr, obj)
32+
33+
34+
def alias_deprecation(func, alias: str):
35+
original = func.__name__
36+
37+
@functools.wraps(func)
38+
def wrapped(*args, **kwargs):
39+
raise DeprecationWarning(
40+
f"The function `{alias}` from PyMC3 was an alias for `{original}` from ArviZ. "
41+
"It was removed in PyMC3 4.0. "
42+
f"Switch to `pymc3.{original}` or `arviz.{original}`."
43+
)
44+
45+
return wrapped
46+
47+
48+
# Aliases of ArviZ functions
49+
autocorrplot = alias_deprecation(az.plot_autocorr, alias="autocorrplot")
50+
forestplot = alias_deprecation(az.plot_forest, alias="forestplot")
51+
kdeplot = alias_deprecation(az.plot_kde, alias="kdeplot")
52+
energyplot = alias_deprecation(az.plot_energy, alias="energyplot")
53+
densityplot = alias_deprecation(az.plot_density, alias="densityplot")
54+
pairplot = alias_deprecation(az.plot_pair, alias="pairplot")
55+
traceplot = alias_deprecation(az.plot_trace, alias="traceplot")
56+
compareplot = alias_deprecation(az.plot_compare, alias="compareplot")
57+
58+
2859
from pymc3.plots.posteriorplot import plot_posterior_predictive_glm
2960

30-
__all__ = ["plot_posterior_predictive_glm"]
61+
__all__ = tuple(az.plots.__all__) + (
62+
"autocorrplot",
63+
"compareplot",
64+
"forestplot",
65+
"kdeplot",
66+
"plot_posterior",
67+
"traceplot",
68+
"energyplot",
69+
"densityplot",
70+
"pairplot",
71+
"plot_posterior_predictive_glm",
72+
)

pymc3/stats/__init__.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2021 The PyMC Developers
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Alias for the `stats` submodule from ArviZ.
16+
17+
Diagnostics and auxiliary statistical functions are delegated to the ArviZ library, a general
18+
purpose library for "exploratory analysis of Bayesian models."
19+
See https://arviz-devs.github.io/arviz/ for details.
20+
"""
21+
import sys
22+
23+
import arviz as az
24+
25+
for attr in az.stats.__all__:
26+
obj = getattr(az.stats, attr)
27+
if not attr.startswith("__"):
28+
setattr(sys.modules[__name__], attr, obj)
29+
30+
31+
__all__ = tuple(az.stats.__all__)

0 commit comments

Comments
 (0)