Skip to content

Commit 45371a9

Browse files
authored
Remove several functions and objects from PyMC root namespace
1 parent fc7493a commit 45371a9

50 files changed

Lines changed: 581 additions & 249 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
tests/test_util.py
6161
tests/test_pytensorf.py
6262
tests/test_math.py
63+
tests/test_root_namespace.py
6364
tests/backends/test_base.py
6465
tests/backends/test_ndarray.py
6566
tests/step_methods/hmc/test_hmc.py

docs/source/api.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ API
1616
api/data
1717
api/ode
1818
api/logprob
19+
api/stats
1920
api/tuning
2021
api/math
2122
api/pytensorf
@@ -43,11 +44,11 @@ Plots, stats and diagnostics are delegated to the
4344
library, a general purpose library for
4445
"exploratory analysis of Bayesian models".
4546

46-
* Functions from the ``arviz.plots`` module are available through ``pymc.<function>`` or ``pymc.plots.<function>``,
47-
but for their API documentation please refer to the :ref:`ArviZ documentation <arviz:plot_api>`.
47+
* Functions from the ``arviz_plots`` package are available through ``pymc.plots.<function>``,
48+
but for their API documentation please refer to the :doc:`arviz_plots documentation <arviz_plots:index>`.
4849

49-
* Functions from the ``arviz.stats`` module are available through ``pymc.<function>`` or ``pymc.stats.<function>``,
50-
but for their API documentation please refer to the :ref:`ArviZ documentation <arviz:stats_api>`.
50+
* Functions from the ``arviz_stats`` package are available through ``pymc.stats.<function>``,
51+
but for their API documentation please refer to the :doc:`arviz_stats documentation <arviz_stats:index>`.
5152

5253
ArviZ is a dependency of PyMC and so, in addition to the locations described above,
5354
importing ArviZ and using ``arviz.<function>`` will also work without any extra installation.

docs/source/api/math.rst

Lines changed: 5 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -2,115 +2,10 @@
22
Math
33
====
44

5-
This submodule contains various mathematical functions. Most of them are imported directly
6-
from pytensor.tensor (see there for more details). Doing any kind of math with PyMC random
7-
variables, or defining custom likelihoods or priors requires you to use these PyTensor
8-
expressions rather than NumPy or Python code.
9-
10-
.. currentmodule:: pymc
11-
12-
Functions exposed in pymc namespace
13-
-----------------------------------
14-
.. autosummary::
15-
:toctree: generated/
16-
17-
expand_packed_triangular
18-
logit
19-
invlogit
20-
probit
21-
invprobit
22-
logaddexp
23-
logsumexp
24-
25-
26-
Functions exposed in pymc.math
27-
------------------------------
5+
This submodule contains various mathematical functions. Most are re-exported directly from
6+
:mod:`pytensor.tensor` and :mod:`pytensor.tensor.linalg` (see there for full signatures and
7+
details). Doing any kind of math with PyMC random variables, or defining custom likelihoods
8+
or priors, requires you to use these PyTensor expressions rather than NumPy or Python code.
289

2910
.. automodule:: pymc.math
30-
.. autosummary::
31-
:toctree: generated/
32-
33-
abs
34-
prod
35-
dot
36-
eq
37-
neq
38-
ge
39-
gt
40-
le
41-
lt
42-
exp
43-
log
44-
sgn
45-
sqr
46-
sqrt
47-
sum
48-
ceil
49-
floor
50-
sin
51-
sinh
52-
arcsin
53-
arcsinh
54-
cos
55-
cosh
56-
arccos
57-
arccosh
58-
tan
59-
tanh
60-
arctan
61-
arctanh
62-
cumprod
63-
cumsum
64-
matmul
65-
and_
66-
broadcast_to
67-
clip
68-
concatenate
69-
flatten
70-
or_
71-
stack
72-
switch
73-
where
74-
flatten_list
75-
constant
76-
max
77-
maximum
78-
mean
79-
min
80-
minimum
81-
round
82-
erf
83-
erfc
84-
erfcinv
85-
erfinv
86-
log1pexp
87-
log1mexp
88-
logaddexp
89-
logsumexp
90-
logdiffexp
91-
logit
92-
invlogit
93-
probit
94-
invprobit
95-
sigmoid
96-
softmax
97-
log_softmax
98-
logbern
99-
full
100-
full_like
101-
ones
102-
ones_like
103-
zeros
104-
zeros_like
105-
kronecker
106-
cartesian
107-
kron_dot
108-
kron_solve_lower
109-
kron_solve_upper
110-
kron_diag
111-
flat_outer
112-
expand_packed_triangular
113-
batched_diag
114-
block_diagonal
115-
matrix_inverse
116-
logdet
11+
:members:

docs/source/api/misc.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ Other utils
66
.. autosummary::
77
:toctree: generated/
88

9-
compute_log_likelihood
10-
compute_log_prior
119
find_constrained_prior
10+
11+
.. currentmodule:: pymc.blocking
12+
13+
.. autosummary::
14+
:toctree: generated/
15+
1216
DictToArrayBijection
1317
model_table

docs/source/api/stats.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Stats
2+
*****
3+
4+
.. currentmodule:: pymc.stats
5+
6+
.. autosummary::
7+
:toctree: generated/
8+
9+
compute_log_prior
10+
compute_log_likelihood
11+
12+
PyMC re-exports functions from the ``arviz_stats`` library under the ``pymc.stats``
13+
namespace, allowing functions like ``summary``, ``ess``, ``rhat``, ``loo`` etc. to be
14+
accessed as ``pymc.stats.<function>``. For the API documentation of those functions,
15+
see the :doc:`arviz_stats documentation <arviz_stats:index>`.

docs/source/api/vi.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@ Variational Inference
1111
ASVGD
1212
SVGD
1313
FullRankADVI
14+
fit
15+
16+
.. currentmodule:: pymc.variational
17+
18+
.. autosummary::
19+
:toctree: generated/
20+
1421
ImplicitGradient
1522
Inference
1623
KLqp
17-
fit
1824

1925
Approximations
2026
--------------
2127

28+
.. currentmodule:: pymc
29+
2230
.. autosummary::
2331
:toctree: generated/
2432

@@ -33,9 +41,15 @@ OPVI
3341
.. autosummary::
3442
:toctree: generated/
3543

36-
Approximation
3744
Group
3845

46+
.. currentmodule:: pymc.variational
47+
48+
.. autosummary::
49+
:toctree: generated/
50+
51+
Approximation
52+
3953
Operators
4054
---------
4155

@@ -48,11 +62,16 @@ Operators
4862

4963
Special
5064
-------
51-
.. currentmodule:: pymc
65+
.. currentmodule:: pymc.variational
5266
.. autosummary::
5367
:toctree: generated/
5468

5569
Stein
70+
71+
.. currentmodule:: pymc
72+
.. autosummary::
73+
:toctree: generated/
74+
5675
adadelta
5776
adagrad
5877
adagrad_window

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@
299299
# intersphinx configuration to ease linking arviz docs
300300
intersphinx_mapping = {
301301
"arviz": ("https://python.arviz.org/en/latest/", None),
302+
"arviz_plots": ("https://python.arviz.org/projects/plots/en/latest/", None),
303+
"arviz_stats": ("https://python.arviz.org/projects/stats/en/latest/", None),
302304
"pytensor": ("https://pytensor.readthedocs.io/en/latest/", None),
303305
"home": ("https://www.pymc.io", None),
304306
"pmx": ("https://www.pymc.io/projects/experimental/en/latest", None),

docs/source/contributing/developer_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ Moreover, if we are limiting to the problem that we can solved most confidently
525525
## Inference
526526

527527
### MCMC
528-
The ability for model instance to generate conditional logp and dlogp function enable one of the unique feature of PyMC - {class}`~pymc.CompoundStep` method.
528+
The ability for model instance to generate conditional logp and dlogp function enable one of the unique feature of PyMC - {class}`~pymc.step_methods.CompoundStep` method.
529529
On a conceptual level it is a Metropolis-within-Gibbs sampler.
530530
Users can specify different sampler for different RVs.
531531
Alternatively, it is implemented as yet another interceptor:

docs/source/learn/core_notebooks/model_comparison.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@
565565
"\n",
566566
"## Reference\n",
567567
"\n",
568-
"[Gelman, A., Hwang, J., & Vehtari, A. (2014). Understanding predictive information criteria for Bayesian models. Statistics and Computing, 24(6), 997–1016.](https://doi.org/10.1007/s11222-013-9416-2)\n",
568+
"[Gelman, A., Hwang, J., & Vehtari, A. (2014). Understanding predictive information criteria for Bayesian models. Statistics and Computing, 24(6), 997\u20131016.](https://doi.org/10.1007/s11222-013-9416-2)\n",
569569
"\n",
570570
"[Vehtari, A, Gelman, A, Gabry, J. (2016). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing](http://link.springer.com/article/10.1007/s11222-016-9696-4)"
571571
]

docs/source/learn/usage_overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Models are defined using a context manager (``with`` statement). The model is sp
3333
beta = pm.Normal('beta', 0, sigma=1)
3434

3535
# Linear combination of parameters
36-
theta = pm.invlogit(alpha + beta * dose)
36+
theta = pm.math.invlogit(alpha + beta * dose)
3737

3838
# Model likelihood
3939
deaths = pm.Binomial('deaths', n=n, p=theta, observed=y)

0 commit comments

Comments
 (0)