Skip to content

replace deprecationwarning with futurewarning #5109

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 2 commits into from
Oct 28, 2021
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
2 changes: 1 addition & 1 deletion pymc/backends/tracetab.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def trace_to_dataframe(trace, chains=None, varnames=None, include_transformed=Fa
"The `trace_to_dataframe` function will soon be removed. "
"Please use ArviZ to save traces. "
"If you have good reasons for using the `trace_to_dataframe` function, file an issue and tell us about them. ",
DeprecationWarning,
FutureWarning,
)
var_shapes = trace._straces[0].var_shapes

Expand Down
2 changes: 1 addition & 1 deletion pymc/distributions/dist_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def log_i0(x):
def incomplete_beta(a, b, value):
warnings.warn(
"incomplete_beta has been deprecated. Use aesara.tensor.betainc instead.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)
return at.betainc(a, b, value)
6 changes: 3 additions & 3 deletions pymc/distributions/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __new__(cls, name, bases, clsdict):
def _random(*args, **kwargs):
warnings.warn(
"The old `Distribution.random` interface is deprecated.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)
return clsdict["random"](*args, **kwargs)
Expand Down Expand Up @@ -204,7 +204,7 @@ def __new__(
initval = kwargs.pop("testval")
warnings.warn(
"The `testval` argument is deprecated; use `initval`.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -296,7 +296,7 @@ def dist(
"The `.dist(testval=...)` argument is deprecated and has no effect. "
"Initial values for sampling/optimization can be specified with `initval` in a modelcontext. "
"For using Aesara's test value features, you must assign the `.tag.test_value` yourself.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)
if "initval" in kwargs:
Expand Down
6 changes: 3 additions & 3 deletions pymc/distributions/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ def __init__(self, eta=None, n=None, p=None, transform="interval", *args, **kwar
"Parameters to LKJCorr have changed: shape parameter n -> eta "
"dimension parameter p -> n. Please update your code. "
"Automatically re-assigning parameters for backwards compatibility.",
DeprecationWarning,
FutureWarning,
)
self.n = p
self.eta = n
Expand All @@ -1435,7 +1435,7 @@ def __init__(self, eta=None, n=None, p=None, transform="interval", *args, **kwar
warnings.warn(
"Parameters in LKJCorr have been rename: shape parameter n -> eta "
"dimension parameter p -> n. Please double check your initialization.",
DeprecationWarning,
FutureWarning,
)
self.tri_index = np.zeros([n, n], dtype="int32")
self.tri_index[np.triu_indices(n, k=1)] = np.arange(shape)
Expand Down Expand Up @@ -1665,7 +1665,7 @@ def dist(
"The shape argument in MatrixNormal is deprecated and will be ignored."
"MatrixNormal automatically derives the shape"
"from row and column matrix dimensions.",
DeprecationWarning,
FutureWarning,
)

# Among-row matrices
Expand Down
2 changes: 1 addition & 1 deletion pymc/gp/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ def marginal_likelihood(self, name, X, Xu, y, noise=None, is_observed=True, **kw
self.sigma = sigma
warnings.warn(
"The 'sigma' argument has been deprecated. Use 'noise' instead.",
DeprecationWarning,
FutureWarning,
)
else:
self.sigma = noise
Expand Down
2 changes: 1 addition & 1 deletion pymc/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def invlogit(x, eps=None):
if eps is not None:
warnings.warn(
"pymc.math.invlogit no longer supports the ``eps`` argument and it will be ignored.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)
return at.sigmoid(x)
Expand Down
10 changes: 5 additions & 5 deletions pymc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def datalogpt(self):
def vars(self):
warnings.warn(
"Model.vars has been deprecated. Use Model.value_vars instead.",
DeprecationWarning,
FutureWarning,
)
return self.value_vars

Expand Down Expand Up @@ -942,7 +942,7 @@ def test_point(self) -> Dict[str, np.ndarray]:
"""Deprecated alias for `Model.recompute_initial_point(seed=None)`."""
warnings.warn(
"`Model.test_point` has been deprecated. Use `Model.recompute_initial_point(seed=None)`.",
DeprecationWarning,
FutureWarning,
)
return self.recompute_initial_point()

Expand All @@ -951,7 +951,7 @@ def initial_point(self) -> Dict[str, np.ndarray]:
"""Deprecated alias for `Model.recompute_initial_point(seed=None)`."""
warnings.warn(
"`Model.initial_point` has been deprecated. Use `Model.recompute_initial_point(seed=None)`.",
DeprecationWarning,
FutureWarning,
)
return self.recompute_initial_point()

Expand Down Expand Up @@ -1548,7 +1548,7 @@ def update_start_vals(self, a: Dict[str, np.ndarray], b: Dict[str, np.ndarray]):
conditional on the values of `b` and stored in `b`.

"""
raise DeprecationWarning(
raise FutureWarning(
"The `Model.update_start_vals` method was removed."
" To change initial values you may set the items of `Model.initial_values` directly."
)
Expand Down Expand Up @@ -1630,7 +1630,7 @@ def check_start_vals(self, start):
def check_test_point(self, *args, **kwargs):
warnings.warn(
"`Model.check_test_point` has been deprecated. Use `Model.point_logps` instead.",
DeprecationWarning,
FutureWarning,
)
return self.point_logps(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion pymc/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def alias_deprecation(func, alias: str):

@functools.wraps(func)
def wrapped(*args, **kwargs):
raise DeprecationWarning(
raise FutureWarning(
f"The function `{alias}` from PyMC was an alias for `{original}` from ArviZ. "
"It was removed in PyMC 4.0. "
f"Switch to `pymc.{original}` or `arviz.{original}`."
Expand Down
2 changes: 1 addition & 1 deletion pymc/plots/posteriorplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def plot_posterior_predictive_glm(
warnings.warn(
"The `plot_posterior_predictive_glm` function will migrate to Arviz in a future release. "
"\nKeep up to date with `ArviZ <https://arviz-devs.github.io/arviz/>`_ for future updates.",
DeprecationWarning,
FutureWarning,
)

if lm is None:
Expand Down
6 changes: 3 additions & 3 deletions pymc/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ def sample_posterior_predictive(
warnings.warn(
"In this version, RNG seeding is managed by the Model objects. "
"See the `rng_seeder` argument in Model's constructor.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -1806,7 +1806,7 @@ def sample_posterior_predictive_w(
warnings.warn(
"In this version, RNG seeding is managed by the Model objects. "
"See the `rng_seeder` argument in Model's constructor.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)

Expand Down Expand Up @@ -1973,7 +1973,7 @@ def sample_prior_predictive(
warnings.warn(
"In this version, RNG seeding is managed by the Model objects. "
"See the `rng_seeder` argument in Model's constructor.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)

Expand Down
8 changes: 4 additions & 4 deletions pymc/smc/sample_smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def sample_smc(
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`",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)
kernel = IMH
Expand All @@ -160,23 +160,23 @@ def sample_smc(
warnings.warn(
"save_sim_data has been deprecated. Use pm.sample_posterior_predictive "
"to obtain the same type of samples.",
DeprecationWarning,
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.",
DeprecationWarning,
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.",
DeprecationWarning,
FutureWarning,
stacklevel=2,
)
if parallel is False:
Expand Down
2 changes: 1 addition & 1 deletion pymc/tests/test_dist_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,6 @@ def ref_multigammaln(a, b):


def test_incomplete_beta_deprecation():
with pytest.warns(DeprecationWarning, match="incomplete_beta has been deprecated"):
with pytest.warns(FutureWarning, match="incomplete_beta has been deprecated"):
res = incomplete_beta(3, 5, 0.5).eval()
assert np.isclose(res, at.betainc(3, 5, 0.5).eval())
2 changes: 1 addition & 1 deletion pymc/tests/test_distributions_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@ def test_errors(self):
logpt(matrixnormal, aesara.tensor.ones((3, 3, 3)))

with pm.Model():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
matrixnormal = pm.MatrixNormal(
"matnormal",
mu=np.random.random((3, 3)),
Expand Down
4 changes: 2 additions & 2 deletions pymc/tests/test_initial_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def transform_back(rv, transformed) -> np.ndarray:

class TestInitvalAssignment:
def test_dist_warnings_and_errors(self):
with pytest.warns(DeprecationWarning, match="argument is deprecated and has no effect"):
with pytest.warns(FutureWarning, match="argument is deprecated and has no effect"):
rv = pm.Exponential.dist(lam=1, testval=0.5)
assert not hasattr(rv.tag, "test_value")

Expand All @@ -42,7 +42,7 @@ def test_dist_warnings_and_errors(self):

def test_new_warnings(self):
with pm.Model() as pmodel:
with pytest.warns(DeprecationWarning, match="`testval` argument is deprecated"):
with pytest.warns(FutureWarning, match="`testval` argument is deprecated"):
rv = pm.Uniform("u", 0, 1, testval=0.75)
initial_point = pmodel.recompute_initial_point(seed=0)
assert initial_point["u_interval__"] == transform_fwd(rv, 0.75)
Expand Down
2 changes: 1 addition & 1 deletion pymc/tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_expand_packed_triangular():

def test_invlogit_deprecation_warning():
with pytest.warns(
DeprecationWarning,
FutureWarning,
match="pymc.math.invlogit no longer supports the",
):
res = invlogit(np.array(-750.0), 1e-5).eval()
Expand Down
8 changes: 4 additions & 4 deletions pymc/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def test_model_vars():
a = pm.Normal("a")
pm.Normal("x", a)

with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
old_vars = model.vars

assert old_vars == model.value_vars
Expand Down Expand Up @@ -495,14 +495,14 @@ def test_initial_point():
a = pm.Uniform("a")
x = pm.Normal("x", a)

with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
initial_point = model.test_point

assert all(var.name in initial_point for var in model.value_vars)

b_initval = np.array(0.3, dtype=aesara.config.floatX)

with pytest.warns(DeprecationWarning), model:
with pytest.warns(FutureWarning), model:
b = pm.Uniform("b", testval=b_initval)

b_value_var = model.rvs_to_values[b]
Expand All @@ -526,7 +526,7 @@ def test_point_logps():
a = pm.Uniform("a")
pm.Normal("x", a)

with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
logp_vals = model.check_test_point()

assert "x" in logp_vals.keys()
Expand Down
10 changes: 5 additions & 5 deletions pymc/tests/test_smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,33 +212,33 @@ def test_convergence_checks(self):
def test_deprecated_parallel_arg(self):
with self.fast_model:
with pytest.warns(
DeprecationWarning,
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(
DeprecationWarning,
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(
DeprecationWarning,
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(
DeprecationWarning,
FutureWarning,
match="save_sim_data has been deprecated",
):
pm.sample_smc(draws=10, chains=1, save_sim_data=True)

with pytest.warns(
DeprecationWarning,
FutureWarning,
match="save_log_pseudolikelihood has been deprecated",
):
pm.sample_smc(draws=10, chains=1, save_log_pseudolikelihood=True)
Expand Down
2 changes: 1 addition & 1 deletion pymc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def enhanced(*args, **kwargs):
def dataset_to_point_dict(ds: xarray.Dataset) -> List[Dict[str, np.ndarray]]:
warnings.warn(
"dataset_to_point_dict was renamed to dataset_to_point_list and will be removed!",
DeprecationWarning,
FutureWarning,
)
return dataset_to_point_list(ds)

Expand Down