From 1eee075620e4554a3bcb2457c315d8df7b2606f6 Mon Sep 17 00:00:00 2001 From: Debian Science Maintainers Date: Sun, 21 Apr 2024 20:55:32 +0100 Subject: [PATCH] Ignore extra warnings that may occur on mips* Some mips* hardware seems to emit RuntimeWarning: invalid value encountered in multiply on multiplication by explicit np.nan, which breaks these tests. Author: Rebecca N. Palmer Forwarded: no Gbp-Pq: Name mips_ignore_nan_warnings.patch --- statsmodels/discrete/tests/test_discrete.py | 4 +++- statsmodels/regression/tests/test_regression.py | 4 +++- statsmodels/tsa/holtwinters/tests/test_holtwinters.py | 11 +++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/statsmodels/discrete/tests/test_discrete.py b/statsmodels/discrete/tests/test_discrete.py index e644201..6c544ad 100644 --- a/statsmodels/discrete/tests/test_discrete.py +++ b/statsmodels/discrete/tests/test_discrete.py @@ -27,6 +27,7 @@ import pandas as pd import pytest from scipy import stats from scipy.stats import nbinom +import platform import statsmodels.api as sm from statsmodels.discrete.discrete_margins import _iscount, _isdummy @@ -2540,7 +2541,8 @@ def test_optim_kwds_prelim(): def test_unchanging_degrees_of_freedom(): data = load_randhie() # see GH3734 - warnings.simplefilter('error') + if 'mips' not in platform.uname()[4]: + warnings.simplefilter('error') model = sm.NegativeBinomial(data.endog, data.exog, loglike_method='nb2') params = np.array([-0.05654134, -0.21213734, 0.08783102, -0.02991825, 0.22902315, 0.06210253, 0.06799444, 0.08406794, diff --git a/statsmodels/regression/tests/test_regression.py b/statsmodels/regression/tests/test_regression.py index cb592b3..efc8041 100644 --- a/statsmodels/regression/tests/test_regression.py +++ b/statsmodels/regression/tests/test_regression.py @@ -5,6 +5,7 @@ Test functions for models.regression from statsmodels.compat.python import lrange import warnings +import platform import numpy as np from numpy.testing import ( @@ -1606,7 +1607,8 @@ def test_ols_constant(reset_randomstate): with warnings.catch_warnings(record=True) as recording: assert np.isnan(res.fvalue) assert np.isnan(res.f_pvalue) - assert len(recording) == 0 + if 'mips' not in platform.uname()[4]: + assert len(recording) == 0 def test_summary_no_constant(): diff --git a/statsmodels/tsa/holtwinters/tests/test_holtwinters.py b/statsmodels/tsa/holtwinters/tests/test_holtwinters.py index b7ba02d..8c7046e 100644 --- a/statsmodels/tsa/holtwinters/tests/test_holtwinters.py +++ b/statsmodels/tsa/holtwinters/tests/test_holtwinters.py @@ -18,6 +18,8 @@ from numpy.testing import assert_allclose, assert_almost_equal import pandas as pd import pytest import scipy.stats +import contextlib +import platform from statsmodels.tools.sm_exceptions import ConvergenceWarning, ValueWarning from statsmodels.tsa.holtwinters import ( @@ -835,8 +837,9 @@ def test_infer_freq(): mod = ExponentialSmoothing( hd2, trend="add", seasonal="add", initialization_method="estimated" ) - assert len(w) == 1 - assert "ValueWarning" in str(w[0]) + if 'mips' not in platform.uname()[4]: + assert len(w) == 1 + assert "ValueWarning" in str(w[0])+str(w[-1]) assert mod.seasonal_periods == 12 @@ -2026,7 +2029,7 @@ def test_forecast_index_types(ses, index_typ): ses = ses.copy() ses.index = index[:-36] - with pytest_warns(warning): + with (contextlib.nullcontext() if (warning is None and 'mips' in platform.uname()[4]) else pytest_warns(warning)): res = ExponentialSmoothing( ses, trend="add", @@ -2034,7 +2037,7 @@ def test_forecast_index_types(ses, index_typ): initialization_method="heuristic", **kwargs ).fit() - with pytest_warns(warning): + with (contextlib.nullcontext() if (warning is None and 'mips' in platform.uname()[4]) else pytest_warns(warning)): fcast = res.forecast(36) assert isinstance(fcast, pd.Series) pd.testing.assert_index_equal(fcast.index, fcast_index) -- 2.30.2