From e255553ad61ed76041b5fbf12658a5bb8cfac82b Mon Sep 17 00:00:00 2001 From: Virgile Andreani Date: Thu, 10 Oct 2024 10:05:22 +0200 Subject: [PATCH 1/4] Remove deprecated assert_negative_support --- pymc/distributions/continuous.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pymc/distributions/continuous.py b/pymc/distributions/continuous.py index afaa142bff..286e508bf2 100644 --- a/pymc/distributions/continuous.py +++ b/pymc/distributions/continuous.py @@ -199,17 +199,6 @@ def transform_params(*args): return transforms.Interval(bounds_fn=transform_params) -def assert_negative_support(var, label, distname, value=-1e-6): - warnings.warn( - "The assert_negative_support function will be deprecated in future versions!" - " See https://github.com/pymc-devs/pymc/issues/5162", - DeprecationWarning, - ) - msg = f"The variable specified for {label} has negative support for {distname}, " - msg += "likely making it unsuitable for this parameter." - return Assert(msg)(var, pt.all(pt.ge(var, 0.0))) - - def get_tau_sigma( tau: TensorLike | None = None, sigma: TensorLike | None = None ) -> tuple[TensorVariable, TensorVariable]: From c74057842589e1e0f111e1cdd7df7516d5673c33 Mon Sep 17 00:00:00 2001 From: Virgile Andreani Date: Thu, 10 Oct 2024 10:08:27 +0200 Subject: [PATCH 2/4] Remove deprecated zerosum_axes argument to ZeroSumNormal --- pymc/distributions/multivariate.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/pymc/distributions/multivariate.py b/pymc/distributions/multivariate.py index 55e275be3e..da10b12fa9 100644 --- a/pymc/distributions/multivariate.py +++ b/pymc/distributions/multivariate.py @@ -2709,7 +2709,6 @@ class ZeroSumNormal(Distribution): n_zerosum_axes: int, defaults to 1 Number of axes along which the zero-sum constraint is enforced, starting from the rightmost position. Defaults to 1, i.e the rightmost axis. - zerosum_axes: int, deprecated please use n_zerosum_axes as its successor dims: sequence of strings, optional Dimension names of the distribution. Works the same as for other PyMC distributions. Necessary if ``shape`` is not passed. @@ -2749,15 +2748,7 @@ class ZeroSumNormal(Distribution): rv_type = ZeroSumNormalRV rv_op = ZeroSumNormalRV.rv_op - def __new__( - cls, *args, zerosum_axes=None, n_zerosum_axes=None, support_shape=None, dims=None, **kwargs - ): - if zerosum_axes is not None: - n_zerosum_axes = zerosum_axes - warnings.warn( - "The 'zerosum_axes' parameter is deprecated. Use 'n_zerosum_axes' instead.", - DeprecationWarning, - ) + def __new__(cls, *args, n_zerosum_axes=None, support_shape=None, dims=None, **kwargs): if dims is not None or kwargs.get("observed") is not None: n_zerosum_axes = cls.check_zerosum_axes(n_zerosum_axes) From 9f8a566bc44b8abe2a9a8bfba46d01fe5ff46f45 Mon Sep 17 00:00:00 2001 From: Virgile Andreani Date: Thu, 10 Oct 2024 10:23:39 +0200 Subject: [PATCH 3/4] Remove deprecated arguments in smc/sampling.py --- pymc/smc/sampling.py | 36 ------------------------------------ tests/smc/test_smc.py | 34 ---------------------------------- 2 files changed, 70 deletions(-) diff --git a/pymc/smc/sampling.py b/pymc/smc/sampling.py index 155d531647..a81d34d553 100644 --- a/pymc/smc/sampling.py +++ b/pymc/smc/sampling.py @@ -15,7 +15,6 @@ import logging import multiprocessing import time -import warnings from collections import defaultdict from concurrent.futures import ProcessPoolExecutor, wait @@ -150,41 +149,6 @@ def sample_smc( `link `__ """ - if isinstance(kernel, str) and kernel.lower() in ("abc", "metropolis"): - warnings.warn( - f'The kernel string argument "{kernel}" in sample_smc has been deprecated. ' - f"It is no longer needed to distinguish between `abc` and `metropolis`", - FutureWarning, - stacklevel=2, - ) - kernel = IMH - - if kernel_kwargs.pop("save_sim_data", None) is not None: - warnings.warn( - "save_sim_data has been deprecated. Use pm.sample_posterior_predictive " - "to obtain the same type of samples.", - FutureWarning, - stacklevel=2, - ) - - if kernel_kwargs.pop("save_log_pseudolikelihood", None) is not None: - warnings.warn( - "save_log_pseudolikelihood has been deprecated. This information is " - "now saved as log_likelihood in models with Simulator distributions.", - FutureWarning, - stacklevel=2, - ) - - parallel = kernel_kwargs.pop("parallel", None) - if parallel is not None: - warnings.warn( - "The argument parallel is deprecated, use the argument cores instead.", - FutureWarning, - stacklevel=2, - ) - if parallel is False: - cores = 1 - if cores is None: cores = _cpu_count() diff --git a/tests/smc/test_smc.py b/tests/smc/test_smc.py index 84a5369558..3aa687459e 100644 --- a/tests/smc/test_smc.py +++ b/tests/smc/test_smc.py @@ -236,40 +236,6 @@ def test_convergence_checks(self, caplog): pm.sample_smc(draws=99, progressbar=not _IS_WINDOWS) assert "The number of samples is too small" in caplog.text - def test_deprecated_parallel_arg(self): - with self.fast_model: - with pytest.warns( - FutureWarning, - match="The argument parallel is deprecated", - ): - pm.sample_smc(draws=10, chains=1, parallel=False) - - def test_deprecated_abc_args(self): - with self.fast_model: - with pytest.warns( - FutureWarning, - match='The kernel string argument "ABC" in sample_smc has been deprecated', - ): - pm.sample_smc(draws=10, chains=1, kernel="ABC") - - with pytest.warns( - FutureWarning, - match='The kernel string argument "Metropolis" in sample_smc has been deprecated', - ): - pm.sample_smc(draws=10, chains=1, kernel="Metropolis") - - with pytest.warns( - FutureWarning, - match="save_sim_data has been deprecated", - ): - pm.sample_smc(draws=10, chains=1, save_sim_data=True) - - with pytest.warns( - FutureWarning, - match="save_log_pseudolikelihood has been deprecated", - ): - pm.sample_smc(draws=10, chains=1, save_log_pseudolikelihood=True) - def test_ordered(self): """ Test that initial population respects custom initval, especially when applied From 31c632fdf41b7b8a18f05f19362c83e91c019d53 Mon Sep 17 00:00:00 2001 From: Virgile Andreani Date: Thu, 10 Oct 2024 10:27:12 +0200 Subject: [PATCH 4/4] Remove deprecated sampling_jax.py --- pymc/sampling_jax.py | 20 -------------------- tests/sampling/test_jax.py | 7 ------- 2 files changed, 27 deletions(-) delete mode 100644 pymc/sampling_jax.py diff --git a/pymc/sampling_jax.py b/pymc/sampling_jax.py deleted file mode 100644 index 21b5961a9c..0000000000 --- a/pymc/sampling_jax.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2024 The PyMC Developers -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# This file exists only for backward-compatibility with imports like -# `import pymc.sampling_jax` or `from pymc import sampling_jax`. - -import warnings - -warnings.warn("This module is deprecated, use pymc.sampling.jax", DeprecationWarning) -from pymc.sampling.jax import * # noqa: E402, F403 diff --git a/tests/sampling/test_jax.py b/tests/sampling/test_jax.py index e9db8e7000..d6a8d1021b 100644 --- a/tests/sampling/test_jax.py +++ b/tests/sampling/test_jax.py @@ -47,13 +47,6 @@ ) -def test_old_import_route(): - import pymc.sampling.jax as new_sj - import pymc.sampling_jax as old_sj - - assert set(new_sj.__all__) <= set(dir(old_sj)) - - def test_jax_PosDefMatrix(): x = pt.tensor(name="x", shape=(2, 2), dtype="float32") matrix_pos_def = PosDefMatrix()