Ignore extra warnings that may occur on mips*
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Sat, 11 Nov 2023 20:34:28 +0000 (20:34 +0000)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sat, 11 Nov 2023 20:34:28 +0000 (20:34 +0000)
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 fb79818e3f8d73f36deefb19ed29708510085d9d..6928a0475c6387dc16c8636631e4198cc0f85f65 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 7e6a6784bf2522017bbc22104314eef8fe472b0a..b825dc0e2468184b3d6895d78d6359d6114d77fd 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 23a4cd6febffca922e6138c8d6050ca0de4884a8..a50421ee8011b1417ff8c68f6fb667b628f32bed 100644 (file)
@@ -17,6 +17,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 (
@@ -834,8 +836,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
 
 
@@ -2025,7 +2028,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",
@@ -2033,7 +2036,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)