Skip to content

API backports and deprecation warnings #5389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
+ 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)).
+ 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)).
+ 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)).
+ `pm.Lognormal` is now available as an alias for `pm.Lognormal` (see [#5389](https://github.com/pymc-devs/pymc/pull/5389)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization is wrong, I think the first one should be LogNormal


### Bugfixes
+ A hotfix is applied on import to remain compatible with NumPy 1.22 (see [#5316](https://github.com/pymc-devs/pymc/pull/5316)).
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/environment-dev-py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- mkl-service
- nbsphinx>=0.4
- numpy=1.15
- numpydoc>=0.9
- numpydoc<1.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would using numpydoc! =1.2.0 allow installation of 1.2.1? The PR fix was merged today, the patch release should hopefully not take long, and with that we could forget about the pin completely

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While they labeled it 1.2.0 on GitHub, the PyPI release is just 1.2, so I'm not sure if !=1.2.0 would work.
Also we have the <1.2 on main already.
But I'm now "watching" the numpydoc repo and will get a notification 🔔 when they do the next release.

- pandas=0.24
- pip
- pre-commit>=2.8.0
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/environment-dev-py38.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- libblas=*=*mkl
- mkl-service
- nbsphinx>=0.4
- numpydoc>=0.9
- numpydoc<1.2
- pip
- pre-commit>=2.8.0
- pytest-cov>=2.5
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/environment-dev-py39.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- libblas=*=*mkl
- mkl-service
- nbsphinx>=0.4
- numpydoc>=0.9
- numpydoc<1.2
- pip
- pre-commit>=2.8.0
- pytest-cov>=2.5
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/windows-environment-dev-py38.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
# Extra stuff for dev, testing and docs build
- ipython>=7.16
- nbsphinx>=0.4
- numpydoc>=0.9
- numpydoc<1.2
- pre-commit>=2.8.0
- pytest-cov>=2.5
- pytest>=3.0
Expand Down
2 changes: 2 additions & 0 deletions pymc3/distributions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
Logistic,
LogitNormal,
Lognormal,
LogNormal,
Moyal,
Normal,
Pareto,
Expand Down Expand Up @@ -120,6 +121,7 @@
"Weibull",
"Bound",
"Lognormal",
"LogNormal",
"HalfStudentT",
"ChiSquared",
"HalfNormal",
Expand Down
27 changes: 15 additions & 12 deletions pymc3/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"Gamma",
"Weibull",
"HalfStudentT",
"Lognormal",
"LogNormal",
"ChiSquared",
"HalfNormal",
"Wald",
Expand Down Expand Up @@ -318,7 +318,7 @@ def random(self, point=None, size=None):
size: int, optional

Raises
-------
------
ValueError
"""
raise ValueError("Cannot sample from Flat distribution")
Expand Down Expand Up @@ -375,7 +375,7 @@ def random(self, point=None, size=None):
size: int, optional

Raises
-------
------
ValueError
"""
raise ValueError("Cannot sample from HalfFlat distribution")
Expand Down Expand Up @@ -1710,7 +1710,7 @@ class AsymmetricLaplace(Continuous):
Location parameter

See Also:
--------
---------
`Reference <https://en.wikipedia.org/wiki/Asymmetric_Laplace_distribution>`_
"""

Expand Down Expand Up @@ -1778,7 +1778,7 @@ def logp(self, value):
)


class Lognormal(PositiveContinuous):
class LogNormal(PositiveContinuous):
r"""
Log-normal log-likelihood.

Expand Down Expand Up @@ -1834,10 +1834,10 @@ class Lognormal(PositiveContinuous):

# Example to show that we pass in only ``sigma`` or ``tau`` but not both.
with pm.Model():
x = pm.Lognormal('x', mu=2, sigma=30)
x = pm.LogNormal('x', mu=2, sigma=30)

with pm.Model():
x = pm.Lognormal('x', mu=2, tau=1/100)
x = pm.LogNormal('x', mu=2, tau=1/100)
"""

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

assert_negative_support(tau, "tau", "Lognormal")
assert_negative_support(sigma, "sigma", "Lognormal")
assert_negative_support(tau, "tau", "LogNormal")
assert_negative_support(sigma, "sigma", "LogNormal")

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

def random(self, point=None, size=None):
"""
Draw random values from Lognormal distribution.
Draw random values from LogNormal distribution.

Parameters
----------
Expand All @@ -1885,7 +1885,7 @@ def random(self, point=None, size=None):

def logp(self, value):
"""
Calculate log-probability of Lognormal distribution at specified value.
Calculate log-probability of LogNormal distribution at specified value.

Parameters
----------
Expand All @@ -1911,7 +1911,7 @@ def _distr_parameters_for_repr(self):

def logcdf(self, value):
"""
Compute the log of the cumulative distribution function for Lognormal distribution
Compute the log of the cumulative distribution function for LogNormal distribution
at the specified value.

Parameters
Expand All @@ -1935,6 +1935,9 @@ def logcdf(self, value):
)


Lognormal = LogNormal


class StudentT(Continuous):
r"""
Student's T log-likelihood.
Expand Down
2 changes: 1 addition & 1 deletion pymc3/distributions/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def random(self, point=None, size=None):


Examples
-------
--------
.. code-block:: python

with pm.Model():
Expand Down
4 changes: 2 additions & 2 deletions pymc3/distributions/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def forward(self, x):
Input tensor to be transformed.

Returns
--------
-------
tensor
Transformed tensor.
"""
Expand All @@ -82,7 +82,7 @@ def forward_val(self, x, point):
Test value used to draw (fix) bounds-like transformations

Returns
--------
-------
array_like
Transformed array.
"""
Expand Down
3 changes: 3 additions & 0 deletions pymc3/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,8 +1388,11 @@ def _choose_backend(trace, chain, **kwds) -> Backend:
A trace object for the selected chain
"""
if isinstance(trace, BaseTrace):
if len(trace) > 0:
warnings.warn("Trace-continuation is not supported in v4.", FutureWarning)
return trace
if isinstance(trace, MultiTrace):
warnings.warn("Starting from MultiTrace objects is not supported in v4.", FutureWarning)
return trace._straces[chain]
if trace is None:
return NDArray(**kwds)
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ deprecat
h5py>=2.7
ipython>=7.16
nbsphinx>=0.4
numpydoc>=0.9
numpydoc<1.2
pre-commit>=2.8.0
pytest-cov>=2.5
pytest>=3.0
Expand Down