Skip to content

Commit baec0c3

Browse files
API backports and deprecation warnings (#5389)
* Backwards-compatible rename `Lognormal`→`LogNormal` * Warn about removal of trace-continuation support * Fixup lognormal rename * More fixup * Fix docstring section underlines * Temporarily pin upper numpydoc version Tracking issue #5401 * Temporarily pin upper numpydoc version Tracking issue #5401
1 parent b5bb2e4 commit baec0c3

11 files changed

+29
-20
lines changed

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
+ The `pm.logp(rv, x)` syntax is now available and recommended to make your model code `v4`-ready. Note that this backport is just an alias and much less capable than what's available with `pymc >=4` (see [#5083](https://github.com/pymc-devs/pymc/pulls/5083)).
66
+ The `pm.Distribution(testval=...)` kwarg was deprecated and will be replaced by `pm.Distribution(initval=...)`in `pymc >=4` (see [#5226](https://github.com/pymc-devs/pymc/pulls/5226)).
77
+ The `pm.sample(start=...)` kwarg was deprecated and will be replaced by `pm.sample(initvals=...)`in `pymc >=4` (see [#5226](https://github.com/pymc-devs/pymc/pulls/5226)).
8+
+ `pm.Lognormal` is now available as an alias for `pm.Lognormal` (see [#5389](https://github.com/pymc-devs/pymc/pull/5389)).
89

910
### Bugfixes
1011
+ A hotfix is applied on import to remain compatible with NumPy 1.22 (see [#5316](https://github.com/pymc-devs/pymc/pull/5316)).

conda-envs/environment-dev-py37.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
- mkl-service
1010
- nbsphinx>=0.4
1111
- numpy=1.15
12-
- numpydoc>=0.9
12+
- numpydoc<1.2
1313
- pandas=0.24
1414
- pip
1515
- pre-commit>=2.8.0

conda-envs/environment-dev-py38.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- libblas=*=*mkl
99
- mkl-service
1010
- nbsphinx>=0.4
11-
- numpydoc>=0.9
11+
- numpydoc<1.2
1212
- pip
1313
- pre-commit>=2.8.0
1414
- pytest-cov>=2.5

conda-envs/environment-dev-py39.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- libblas=*=*mkl
99
- mkl-service
1010
- nbsphinx>=0.4
11-
- numpydoc>=0.9
11+
- numpydoc<1.2
1212
- pip
1313
- pre-commit>=2.8.0
1414
- pytest-cov>=2.5

conda-envs/windows-environment-dev-py38.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
# Extra stuff for dev, testing and docs build
1717
- ipython>=7.16
1818
- nbsphinx>=0.4
19-
- numpydoc>=0.9
19+
- numpydoc<1.2
2020
- pre-commit>=2.8.0
2121
- pytest-cov>=2.5
2222
- pytest>=3.0

pymc3/distributions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
Logistic,
3737
LogitNormal,
3838
Lognormal,
39+
LogNormal,
3940
Moyal,
4041
Normal,
4142
Pareto,
@@ -120,6 +121,7 @@
120121
"Weibull",
121122
"Bound",
122123
"Lognormal",
124+
"LogNormal",
123125
"HalfStudentT",
124126
"ChiSquared",
125127
"HalfNormal",

pymc3/distributions/continuous.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"Gamma",
6363
"Weibull",
6464
"HalfStudentT",
65-
"Lognormal",
65+
"LogNormal",
6666
"ChiSquared",
6767
"HalfNormal",
6868
"Wald",
@@ -318,7 +318,7 @@ def random(self, point=None, size=None):
318318
size: int, optional
319319
320320
Raises
321-
-------
321+
------
322322
ValueError
323323
"""
324324
raise ValueError("Cannot sample from Flat distribution")
@@ -375,7 +375,7 @@ def random(self, point=None, size=None):
375375
size: int, optional
376376
377377
Raises
378-
-------
378+
------
379379
ValueError
380380
"""
381381
raise ValueError("Cannot sample from HalfFlat distribution")
@@ -1710,7 +1710,7 @@ class AsymmetricLaplace(Continuous):
17101710
Location parameter
17111711
17121712
See Also:
1713-
--------
1713+
---------
17141714
`Reference <https://en.wikipedia.org/wiki/Asymmetric_Laplace_distribution>`_
17151715
"""
17161716

@@ -1778,7 +1778,7 @@ def logp(self, value):
17781778
)
17791779

17801780

1781-
class Lognormal(PositiveContinuous):
1781+
class LogNormal(PositiveContinuous):
17821782
r"""
17831783
Log-normal log-likelihood.
17841784
@@ -1834,10 +1834,10 @@ class Lognormal(PositiveContinuous):
18341834
18351835
# Example to show that we pass in only ``sigma`` or ``tau`` but not both.
18361836
with pm.Model():
1837-
x = pm.Lognormal('x', mu=2, sigma=30)
1837+
x = pm.LogNormal('x', mu=2, sigma=30)
18381838
18391839
with pm.Model():
1840-
x = pm.Lognormal('x', mu=2, tau=1/100)
1840+
x = pm.LogNormal('x', mu=2, tau=1/100)
18411841
"""
18421842

18431843
def __init__(self, mu=0, sigma=None, tau=None, sd=None, *args, **kwargs):
@@ -1856,16 +1856,16 @@ def __init__(self, mu=0, sigma=None, tau=None, sd=None, *args, **kwargs):
18561856
self.mode = tt.exp(self.mu - 1.0 / self.tau)
18571857
self.variance = (tt.exp(1.0 / self.tau) - 1) * tt.exp(2 * self.mu + 1.0 / self.tau)
18581858

1859-
assert_negative_support(tau, "tau", "Lognormal")
1860-
assert_negative_support(sigma, "sigma", "Lognormal")
1859+
assert_negative_support(tau, "tau", "LogNormal")
1860+
assert_negative_support(sigma, "sigma", "LogNormal")
18611861

18621862
def _random(self, mu, tau, size=None):
18631863
samples = np.random.normal(size=size)
18641864
return np.exp(mu + (tau ** -0.5) * samples)
18651865

18661866
def random(self, point=None, size=None):
18671867
"""
1868-
Draw random values from Lognormal distribution.
1868+
Draw random values from LogNormal distribution.
18691869
18701870
Parameters
18711871
----------
@@ -1885,7 +1885,7 @@ def random(self, point=None, size=None):
18851885

18861886
def logp(self, value):
18871887
"""
1888-
Calculate log-probability of Lognormal distribution at specified value.
1888+
Calculate log-probability of LogNormal distribution at specified value.
18891889
18901890
Parameters
18911891
----------
@@ -1911,7 +1911,7 @@ def _distr_parameters_for_repr(self):
19111911

19121912
def logcdf(self, value):
19131913
"""
1914-
Compute the log of the cumulative distribution function for Lognormal distribution
1914+
Compute the log of the cumulative distribution function for LogNormal distribution
19151915
at the specified value.
19161916
19171917
Parameters
@@ -1935,6 +1935,9 @@ def logcdf(self, value):
19351935
)
19361936

19371937

1938+
Lognormal = LogNormal
1939+
1940+
19381941
class StudentT(Continuous):
19391942
r"""
19401943
Student's T log-likelihood.

pymc3/distributions/timeseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def random(self, point=None, size=None):
484484
485485
486486
Examples
487-
-------
487+
--------
488488
.. code-block:: python
489489
490490
with pm.Model():

pymc3/distributions/transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def forward(self, x):
6464
Input tensor to be transformed.
6565
6666
Returns
67-
--------
67+
-------
6868
tensor
6969
Transformed tensor.
7070
"""
@@ -82,7 +82,7 @@ def forward_val(self, x, point):
8282
Test value used to draw (fix) bounds-like transformations
8383
8484
Returns
85-
--------
85+
-------
8686
array_like
8787
Transformed array.
8888
"""

pymc3/sampling.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,8 +1388,11 @@ def _choose_backend(trace, chain, **kwds) -> Backend:
13881388
A trace object for the selected chain
13891389
"""
13901390
if isinstance(trace, BaseTrace):
1391+
if len(trace) > 0:
1392+
warnings.warn("Trace-continuation is not supported in v4.", FutureWarning)
13911393
return trace
13921394
if isinstance(trace, MultiTrace):
1395+
warnings.warn("Starting from MultiTrace objects is not supported in v4.", FutureWarning)
13931396
return trace._straces[chain]
13941397
if trace is None:
13951398
return NDArray(**kwds)

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ deprecat
55
h5py>=2.7
66
ipython>=7.16
77
nbsphinx>=0.4
8-
numpydoc>=0.9
8+
numpydoc<1.2
99
pre-commit>=2.8.0
1010
pytest-cov>=2.5
1111
pytest>=3.0

0 commit comments

Comments
 (0)