Ignore extra warnings that may occur on mips*
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Sun, 1 Sep 2024 10:18:24 +0000 (11:18 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sun, 1 Sep 2024 10:18:24 +0000 (11:18 +0100)
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 <rebecca_palmer@zoho.com>
Forwarded: no

Gbp-Pq: Name mips_ignore_nan_warnings.patch

statsmodels/discrete/tests/test_discrete.py
statsmodels/regression/tests/test_regression.py
statsmodels/tsa/holtwinters/tests/test_holtwinters.py

index e6442015a1feab39331bfe616f3cf0c07fd607d0..6c544ad03e17f3b30c3cfb2059b619fe59136072 100644 (file)
@@ -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,
index cb592b3ffc0b30a9ade56c40da18c0a5ccf42d61..efc80412bc83f36ac68f5096e820b773b5f0478a 100644 (file)
@@ -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():
index b7ba02d110adbcd9001c7e8e8886710398b8925b..8c7046e32e9f771580fe6eddfe9b51b130039fc3 100644 (file)
@@ -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)