Skip to content

Commit 6292ad9

Browse files
ColCarrolltwiecki
authored andcommitted
Make ArviZ a proper requirement
1 parent 3f3ff78 commit 6292ad9

File tree

5 files changed

+21
-79
lines changed

5 files changed

+21
-79
lines changed

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Added `Matern12` covariance function for Gaussian processes. This is the Matern kernel with nu=1/2.
1010
- Progressbar reports number of divergences in real time, when available [#3547](https://github.com/pymc-devs/pymc3/pull/3547).
1111
- Sampling from variational approximation now allows for alternative trace backends [#3550].
12+
- [ArviZ](https://arviz-devs.github.io/arviz/) is now a requirement, and handles plotting, diagnostics, and statistical checks.
1213

1314
### Maintenance
1415
- Moved math operations out of `Rice`, `TruncatedNormal`, `Triangular` and `ZeroInflatedNegativeBinomial` `random` methods. Math operations on values returned by `draw_values` might not broadcast well, and all the `size` aware broadcasting is left to `generate_samples`. Fixes [#3481](https://github.com/pymc-devs/pymc3/issues/3481) and [#3508](https://github.com/pymc-devs/pymc3/issues/3508)

pymc3/plots/__init__.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,8 @@
77
import functools
88
import sys
99
import warnings
10-
try:
11-
import arviz as az
12-
except ImportError: # arviz is optional, throw exception when used
1310

14-
class _ImportWarner:
15-
__all__ = []
16-
17-
def __init__(self, attr):
18-
self.attr = attr
19-
20-
def __call__(self, *args, **kwargs):
21-
raise ImportError(
22-
"ArviZ is not installed. In order to use `{0.attr}`:\npip install arviz".format(self)
23-
)
24-
25-
class _ArviZ:
26-
def __getattr__(self, attr):
27-
return _ImportWarner(attr)
28-
29-
30-
az = _ArviZ()
11+
import arviz as az
3112

3213
def map_args(func):
3314
swaps = [

pymc3/stats/__init__.py

Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,13 @@
1-
"""Statistical utility functions for PyMC
1+
"""Statistical utility functions for PyMC3
22
33
Diagnostics and auxiliary statistical functions are delegated to the ArviZ library, a general
44
purpose library for "exploratory analysis of Bayesian models." See
55
https://arviz-devs.github.io/arviz/ for details.
66
"""
77
import functools
8-
import sys
98
import warnings
109

11-
try:
12-
import arviz as az
13-
except ImportError: # arviz is optional, throw exception when used
14-
15-
class _ImportWarner:
16-
__all__ = []
17-
18-
def __init__(self, attr):
19-
self.attr = attr
20-
21-
def __call__(self, *args, **kwargs):
22-
raise ImportError(
23-
"ArviZ is not installed. In order to use `{0.attr}`:\npip install arviz".format(
24-
self
25-
)
26-
)
27-
28-
class _ArviZ:
29-
def __getattr__(self, attr):
30-
return _ImportWarner(attr)
31-
32-
az = _ArviZ()
33-
10+
import arviz as az
3411

3512
def map_args(func):
3613
swaps = [("varnames", "var_names")]
@@ -41,28 +18,14 @@ def wrapped(*args, **kwargs):
4118
if old in kwargs and new not in kwargs:
4219
warnings.warn(
4320
"Keyword argument `{old}` renamed to `{new}`, and will be removed in "
44-
"pymc3 3.8".format(old=old, new=new)
21+
"pymc3 3.9".format(old=old, new=new)
4522
)
4623
kwargs[new] = kwargs.pop(old)
4724
return func(*args, **kwargs)
4825

4926
return wrapped
5027

5128

52-
__all__ = [
53-
"bfmi",
54-
"compare",
55-
"ess",
56-
"geweke",
57-
"hpd",
58-
"loo",
59-
"mcse",
60-
"r2_score",
61-
"rhat",
62-
"summary",
63-
"waic",
64-
]
65-
6629
bfmi = map_args(az.bfmi)
6730
compare = map_args(az.compare)
6831
ess = map_args(az.ess)
@@ -77,31 +40,30 @@ def wrapped(*args, **kwargs):
7740

7841

7942
def gelman_rubin(*args, **kwargs):
80-
warnings.warn("gelman_rubin has been deprecated. In future, use rhat instead.")
43+
warnings.warn("gelman_rubin has been deprecated. In the future, use rhat instead.")
8144
return rhat(*args, **kwargs)
8245

46+
gelman_rubin.__doc__ = rhat.__doc__
47+
8348

8449
def effective_n(*args, **kwargs):
85-
warnings.warn("effective_n has been deprecated. In future, use ess instead.")
50+
warnings.warn("effective_n has been deprecated. In the future, use ess instead.")
8651
return ess(*args, **kwargs)
8752

53+
effective_n.__doc__ = ess.__doc__
8854

89-
# Access to arviz stats: base stats provided by arviz
90-
for stat in az.stats.__all__:
91-
setattr(sys.modules[__name__], stat, map_args(getattr(az.stats, stat)))
92-
93-
__all__ = tuple(az.stats.__all__) + (
55+
__all__ = [
56+
"bfmi",
9457
"compare",
58+
"ess",
59+
"geweke",
9560
"hpd",
9661
"loo",
62+
"mcse",
9763
"r2_score",
64+
"rhat",
9865
"summary",
9966
"waic",
100-
"bfmi",
101-
"ess",
102-
"geweke",
103-
"mcse",
104-
"rhat",
105-
"gelman_rubin",
106-
"effective_n",
107-
)
67+
"gelman_rubin", # deprecated, remove after 3.8
68+
"effective_n", # deprecated, remove after 3.8
69+
]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
arviz>=0.4.1
12
theano>=1.0.4
23
numpy>=1.13.0
34
scipy>=0.18.1

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from codecs import open
33
from os.path import realpath, dirname, join
44
from setuptools import setup, find_packages
5-
import sys
65
import re
76

87
DISTNAME = 'pymc3'
@@ -17,6 +16,7 @@
1716
'Programming Language :: Python :: 3',
1817
'Programming Language :: Python :: 3.5',
1918
'Programming Language :: Python :: 3.6',
19+
'Programming Language :: Python :: 3.7',
2020
'License :: OSI Approved :: Apache Software License',
2121
'Intended Audience :: Science/Research',
2222
'Topic :: Scientific/Engineering',
@@ -61,8 +61,5 @@ def get_version():
6161
classifiers=classifiers,
6262
python_requires=">=3.5.4",
6363
install_requires=install_reqs,
64-
extras_require={
65-
"plots": ["arviz"],
66-
},
6764
tests_require=test_reqs,
6865
test_suite='nose.collector')

0 commit comments

Comments
 (0)