From c51decb58abc9609cc785a98c684d3b8192a494d Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 13:58:04 -0400 Subject: [PATCH 01/12] - Ignore depreciation warning from statsmodel in test_VARMAX.py - Squeeze result vector-matrix multiplication with (1, 1) matrix to avoid shape error in numpy 1.25.2 --- pymc_experimental/tests/statespace/test_VARMAX.py | 1 + pymc_experimental/tests/statespace/utilities/test_helpers.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pymc_experimental/tests/statespace/test_VARMAX.py b/pymc_experimental/tests/statespace/test_VARMAX.py index f923f524..03d8f59b 100644 --- a/pymc_experimental/tests/statespace/test_VARMAX.py +++ b/pymc_experimental/tests/statespace/test_VARMAX.py @@ -96,6 +96,7 @@ def test_VARMAX_param_counts_match_statsmodels(data, order, var): @pytest.mark.parametrize("order", orders, ids=ids) @pytest.mark.filterwarnings("ignore::statsmodels.tools.sm_exceptions.EstimationWarning") +@pytest.mark.filterwarnings("ignore::FutureWarning") def test_VARMAX_update_matches_statsmodels(data, order, rng): p, q = order diff --git a/pymc_experimental/tests/statespace/utilities/test_helpers.py b/pymc_experimental/tests/statespace/utilities/test_helpers.py index 3b093185..e8f58d05 100644 --- a/pymc_experimental/tests/statespace/utilities/test_helpers.py +++ b/pymc_experimental/tests/statespace/utilities/test_helpers.py @@ -227,7 +227,7 @@ def simulate_from_numpy_model(mod, rng, param_dict, steps=100): y = np.zeros(steps) x[0] = x0 - y[0] = Z @ x0 + y[0] = (Z @ x0).squeeze() if not np.allclose(H, 0): y[0] += rng.multivariate_normal(mean=np.zeros(1), cov=H) @@ -245,7 +245,7 @@ def simulate_from_numpy_model(mod, rng, param_dict, steps=100): error = 0 x[t] = c + T @ x[t - 1] + innov - y[t] = d + Z @ x[t] + error + y[t] = (d + Z @ x[t] + error).squeeze() return x, y From d09735638b520309f18a93ae9e666170e6a3d4db Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 14:09:41 -0400 Subject: [PATCH 02/12] Ignore depreciation warning issued by `np.find_common_types` (used by scipy.stats._distn_infrastructure) --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 0b4c86f9..ed5848d3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,7 @@ testpaths = tests filterwarnings = error ignore::DeprecationWarning:numpy.core.fromnumeric + ignore::DeprecationWarning:numpy.core.numerictypes ignore:::arviz.* ignore:DeprecationWarning From 81d9235551a597a66afcb4c3a56696819234fdaf Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 18:12:24 -0400 Subject: [PATCH 03/12] Ignore depreciation warning issued by `np.find_common_types` (used by scipy.stats._distn_infrastructure) --- pytest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest.ini b/pytest.ini index 51b995fe..e73d1a0d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,3 +5,4 @@ filterwarnings = ignore::UserWarning:arviz.data.inference_data ignore::DeprecationWarning:pkg_resources ignore:ml_dtypes.float8_e4m3b11 is deprecated. Use ml_dtypes.float8_e4m3b11fnuz:DeprecationWarning + ignore::DeprecationWarning:numpy.core.numerictypes From a830892d5fe976adb48e18fb43207791449f9998 Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 18:21:55 -0400 Subject: [PATCH 04/12] Ignore np.find_common_type warning --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index e73d1a0d..895d8aec 100644 --- a/pytest.ini +++ b/pytest.ini @@ -4,5 +4,5 @@ filterwarnings = ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8)\b).*:DeprecationWarning ignore::UserWarning:arviz.data.inference_data ignore::DeprecationWarning:pkg_resources + ignore:np.find_common_type is deprecated. Please use `np.result_type` or `np.promote_types`.:DeprecationWarning ignore:ml_dtypes.float8_e4m3b11 is deprecated. Use ml_dtypes.float8_e4m3b11fnuz:DeprecationWarning - ignore::DeprecationWarning:numpy.core.numerictypes From 2c7cc5e6506a5fdb095bbe47c6a4a1e21d0c5c79 Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 19:38:51 -0400 Subject: [PATCH 05/12] Ignore np.cumproduct warning --- pytest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest.ini b/pytest.ini index 895d8aec..e9a60398 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,4 +5,5 @@ filterwarnings = ignore::UserWarning:arviz.data.inference_data ignore::DeprecationWarning:pkg_resources ignore:np.find_common_type is deprecated. Please use `np.result_type` or `np.promote_types`.:DeprecationWarning + ignore:`cumproduct` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `cumprod` instead.:DeprecationWarning ignore:ml_dtypes.float8_e4m3b11 is deprecated. Use ml_dtypes.float8_e4m3b11fnuz:DeprecationWarning From 7a767e9eec44fbe9ab7d077dfd499524820cc995 Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 20:36:06 -0400 Subject: [PATCH 06/12] Consolidate all project settings into `pyproject.toml` --- pyproject.toml | 14 ++++++++++++++ pytest.ini | 9 --------- setup.cfg | 12 ------------ 3 files changed, 14 insertions(+), 21 deletions(-) delete mode 100644 pytest.ini delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index ebc76bc6..d0b66d04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,19 @@ addopts = [ "--ignore=pymc_experimental/model_builder.py" ] +filterwarnings =[ + "error", + "ignore::DeprecationWarning:numpy.core.fromnumeric", + "ignore:::arviz.*", + "ignore:DeprecationWarning", + 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8)\b).*:DeprecationWarning', + "ignore::UserWarning:arviz.data.inference_data", + "ignore::DeprecationWarning:pkg_resources", + 'ignore:np.find_common_type is deprecated. Please use `np.result_type` or `np.promote_types`.:DeprecationWarning', + 'ignore:`cumproduct` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `cumprod` instead.:DeprecationWarning', + 'ignore:`product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.:DeprecationWarning', + 'ignore:ml_dtypes.float8_e4m3b11 is deprecated. Use ml_dtypes.float8_e4m3b11fnuz:DeprecationWarning', +] [tool.black] line-length = 100 @@ -20,6 +33,7 @@ exclude_lines = [ [tool.isort] profile = "black" +lines_between_types = 1 [tool.nbqa.mutate] isort = 1 diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index e9a60398..00000000 --- a/pytest.ini +++ /dev/null @@ -1,9 +0,0 @@ -[pytest] -filterwarnings = - error - ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8)\b).*:DeprecationWarning - ignore::UserWarning:arviz.data.inference_data - ignore::DeprecationWarning:pkg_resources - ignore:np.find_common_type is deprecated. Please use `np.result_type` or `np.promote_types`.:DeprecationWarning - ignore:`cumproduct` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `cumprod` instead.:DeprecationWarning - ignore:ml_dtypes.float8_e4m3b11 is deprecated. Use ml_dtypes.float8_e4m3b11fnuz:DeprecationWarning diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ed5848d3..00000000 --- a/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[tool:pytest] -testpaths = tests -filterwarnings = - error - ignore::DeprecationWarning:numpy.core.fromnumeric - ignore::DeprecationWarning:numpy.core.numerictypes - ignore:::arviz.* - ignore:DeprecationWarning - -[isort] -lines_between_types = 1 -profile = black From 2a5fa0850496b8bb89a3a5cd3e27da82d754f3ef Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 22:42:22 -0400 Subject: [PATCH 07/12] Remove unnecessary filtered warnings --- pyproject.toml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d0b66d04..83cec8b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,16 +9,10 @@ addopts = [ filterwarnings =[ "error", - "ignore::DeprecationWarning:numpy.core.fromnumeric", - "ignore:::arviz.*", - "ignore:DeprecationWarning", - 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8)\b).*:DeprecationWarning', "ignore::UserWarning:arviz.data.inference_data", - "ignore::DeprecationWarning:pkg_resources", - 'ignore:np.find_common_type is deprecated. Please use `np.result_type` or `np.promote_types`.:DeprecationWarning', - 'ignore:`cumproduct` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `cumprod` instead.:DeprecationWarning', - 'ignore:`product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.:DeprecationWarning', - 'ignore:ml_dtypes.float8_e4m3b11 is deprecated. Use ml_dtypes.float8_e4m3b11fnuz:DeprecationWarning', + 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8)\b).*:DeprecationWarning', + 'ignore::DeprecationWarning:.*numpy.core.fromnumeric*', + 'ignore::DeprecationWarning:.*numpy.core.numerictypes*' ] [tool.black] From bd3901a025b154d81933bd7eb3e897543e3338bb Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 23:07:26 -0400 Subject: [PATCH 08/12] Remove unnecessary filtered warnings --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 83cec8b2..59b5fc09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,8 +11,8 @@ filterwarnings =[ "error", "ignore::UserWarning:arviz.data.inference_data", 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8)\b).*:DeprecationWarning', - 'ignore::DeprecationWarning:.*numpy.core.fromnumeric*', - 'ignore::DeprecationWarning:.*numpy.core.numerictypes*' + "ignore::DeprecationWarning:.*numpy.core.fromnumeric*", + "ignore::DeprecationWarning:.*numpy.core.numerictypes*" ] [tool.black] @@ -27,7 +27,7 @@ exclude_lines = [ [tool.isort] profile = "black" -lines_between_types = 1 +# lines_between_types = 1 [tool.nbqa.mutate] isort = 1 From cea96949aace62d26132edfd5724ec5d05316069 Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sat, 7 Oct 2023 23:11:46 -0400 Subject: [PATCH 09/12] Filter numpy deprecation warnings by message --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 59b5fc09..acfb91c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,9 +10,7 @@ addopts = [ filterwarnings =[ "error", "ignore::UserWarning:arviz.data.inference_data", - 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8)\b).*:DeprecationWarning', - "ignore::DeprecationWarning:.*numpy.core.fromnumeric*", - "ignore::DeprecationWarning:.*numpy.core.numerictypes*" + 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8|np\.find_common_type|np\.cumproduct)\b).*:DeprecationWarning', ] [tool.black] From 1a73ae9d67bf29308d512006f3f6e184e270ab56 Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sun, 8 Oct 2023 08:21:26 -0400 Subject: [PATCH 10/12] Filter numpy deprecation warnings by message --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index acfb91c1..e6495734 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ addopts = [ filterwarnings =[ "error", "ignore::UserWarning:arviz.data.inference_data", - 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8|np\.find_common_type|np\.cumproduct)\b).*:DeprecationWarning', + 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8|np\.find_common_type|cumproduct)\b).*:DeprecationWarning', ] [tool.black] From 577591d9c747b639a4dd8ea88fe56a9d65529d00 Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sun, 8 Oct 2023 08:58:29 -0400 Subject: [PATCH 11/12] Add regex match for `product` deprecation --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e6495734..9426a595 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ addopts = [ filterwarnings =[ "error", "ignore::UserWarning:arviz.data.inference_data", - 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8|np\.find_common_type|cumproduct)\b).*:DeprecationWarning', + 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8|np\.find_common_type|cumproduct|product)\b).*:DeprecationWarning', ] [tool.black] From 605a14fddf56740d7cb6e0b02969d7a24c928bb7 Mon Sep 17 00:00:00 2001 From: jessegrabowski Date: Sun, 8 Oct 2023 10:16:29 -0400 Subject: [PATCH 12/12] Change pathfinder jax import from deprecated pymc.sampling_jax to pymc.sampling.jax Skip pathfinder test if python < 3.10 Add some comments to `pyproject.toml` to explain what warnings are being ignored and why --- pymc_experimental/inference/pathfinder.py | 2 +- pymc_experimental/tests/test_pathfinder.py | 3 +++ pyproject.toml | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pymc_experimental/inference/pathfinder.py b/pymc_experimental/inference/pathfinder.py index 85c1981e..94a0bb32 100644 --- a/pymc_experimental/inference/pathfinder.py +++ b/pymc_experimental/inference/pathfinder.py @@ -25,7 +25,7 @@ import numpy as np import pymc as pm from pymc import modelcontext -from pymc.sampling_jax import get_jaxified_graph +from pymc.sampling.jax import get_jaxified_graph from pymc.util import RandomSeed, _get_seeds_per_chain, get_default_varnames diff --git a/pymc_experimental/tests/test_pathfinder.py b/pymc_experimental/tests/test_pathfinder.py index aa680a23..1be2a22c 100644 --- a/pymc_experimental/tests/test_pathfinder.py +++ b/pymc_experimental/tests/test_pathfinder.py @@ -23,6 +23,9 @@ # TODO: Remove this filterwarning after pytensor uses jnp.prod instead of jnp.product @pytest.mark.skipif(sys.platform == "win32", reason="JAX not supported on windows.") +@pytest.mark.skipif( + sys.version_info < (3, 10), reason="pymc.sampling.jax does not currently support python < 3.10" +) @pytest.mark.filterwarnings("ignore::DeprecationWarning") def test_pathfinder(): # Data of the Eight Schools Model diff --git a/pyproject.toml b/pyproject.toml index 9426a595..d1bc518f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,10 @@ addopts = [ filterwarnings =[ "error", + # Raised by arviz when the model_builder class adds non-standard group names to InferenceData "ignore::UserWarning:arviz.data.inference_data", + + # bool8, find_common_type, cumproduct, and product had deprecation warnings added in numpy 1.25 'ignore:.*(\b(pkg_resources\.declare_namespace|np\.bool8|np\.find_common_type|cumproduct|product)\b).*:DeprecationWarning', ]