Skip to content

Commit 64e99fe

Browse files
committed
Ignore DeprecationWarning triggered by arviz
1 parent 5e89b69 commit 64e99fe

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

tests/backends/test_arviz.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
from pymc.exceptions import ImputationWarning
3333

3434
# Turn all warnings into errors for this module
35-
pytestmark = pytest.mark.filterwarnings("error")
35+
pytestmark = pytest.mark.filterwarnings(
36+
"error",
37+
# Related to https://github.com/arviz-devs/arviz/issues/2327
38+
"ignore:datetime.datetime.utcnow():DeprecationWarning",
39+
)
3640

3741

3842
@pytest.fixture(scope="module")
@@ -672,13 +676,17 @@ def test_include_transformed(self):
672676
)
673677
assert "p_interval__" in inference_data.posterior
674678

679+
@pytest.mark.filterwarnings(
680+
"error",
681+
# Related to https://github.com/arviz-devs/arviz/issues/2327
682+
"ignore:datetime.datetime.utcnow():DeprecationWarning",
683+
)
675684
@pytest.mark.parametrize("chains", (1, 2))
676685
def test_single_chain(self, chains):
677686
# Test that no UserWarning is raised when sampling with NUTS defaults
678687

679688
# When this test was added, a `UserWarning: More chains (500) than draws (1)` used to be issued
680689
# when sampling with a single chain
681-
warnings.simplefilter("error")
682690
with pm.Model():
683691
pm.Normal("x")
684692
pm.sample(chains=chains, return_inferencedata=True)

tests/distributions/test_timeseries.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848

4949
# Turn all warnings into errors for this module
5050
# Ignoring NumPy deprecation warning tracked in https://github.com/pymc-devs/pytensor/issues/146
51-
pytestmark = pytest.mark.filterwarnings("error", "ignore: NumPy will stop allowing conversion")
51+
pytestmark = pytest.mark.filterwarnings(
52+
"error",
53+
"ignore: NumPy will stop allowing conversion",
54+
# Related to https://github.com/arviz-devs/arviz/issues/2327
55+
"ignore:datetime.datetime.utcnow():DeprecationWarning",
56+
)
5257

5358

5459
class TestRandomWalk:

tests/sampling/test_mcmc_external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_external_nuts_sampler(recwarn, nuts_sampler):
4747
warns = {
4848
(warn.category, warn.message.args[0])
4949
for warn in recwarn
50-
if warn.category is not FutureWarning
50+
if warn.category not in (FutureWarning, DeprecationWarning)
5151
}
5252
expected = set()
5353
if nuts_sampler == "nutpie":

tests/variational/test_inference.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ def test_fit_oo(inference, fit_kwargs, simple_model_data):
172172
warn_ctxt = nullcontext()
173173

174174
with warn_ctxt:
175-
trace = inference.fit(**fit_kwargs).sample(10000)
175+
with warnings.catch_warnings():
176+
# Related to https://github.com/arviz-devs/arviz/issues/2327
177+
warnings.filterwarnings(
178+
"ignore", message="datetime.datetime.utcnow()", category=DeprecationWarning
179+
)
180+
181+
trace = inference.fit(**fit_kwargs).sample(10000)
176182
mu_post = simple_model_data["mu_post"]
177183
d = simple_model_data["d"]
178184
np.testing.assert_allclose(np.mean(trace.posterior["mu"]), mu_post, rtol=0.05)
@@ -207,10 +213,16 @@ def test_fit_start(inference_spec, simple_model):
207213
expected_warning = observed_value.name.startswith("minibatch")
208214
with warnings.catch_warnings(record=True) as record:
209215
warnings.simplefilter("always")
210-
try:
211-
trace = inference.fit(n=0).sample(10000)
212-
except NotImplementedInference as e:
213-
pytest.skip(str(e))
216+
with warnings.catch_warnings():
217+
# Related to https://github.com/arviz-devs/arviz/issues/2327
218+
warnings.filterwarnings(
219+
"ignore", message="datetime.datetime.utcnow()", category=DeprecationWarning
220+
)
221+
222+
try:
223+
trace = inference.fit(n=0).sample(10000)
224+
except NotImplementedInference as e:
225+
pytest.skip(str(e))
214226

215227
if expected_warning:
216228
assert len(record) > 0

0 commit comments

Comments
 (0)