Avoid cast exception in np.bincount
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Sat, 5 Oct 2024 10:43:25 +0000 (11:43 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sat, 5 Oct 2024 10:43:25 +0000 (11:43 +0100)
Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Bug-Debian: https://bugs.debian.org/1030208
Forwarded: no

Gbp-Pq: Name 1030208_scipy1p10.patch

statsmodels/distributions/tests/test_discrete.py

index 609198787e1508699eb344f8ad5fe2bfd3ecdf0a..18bf982094302dbda61ab293a56a9ead5d7ad8d4 100644 (file)
@@ -1,5 +1,6 @@
 import numpy as np
 from numpy.testing import assert_allclose, assert_equal
+import sys
 
 from scipy import stats
 from scipy.stats import poisson, nbinom
@@ -335,7 +336,8 @@ class CheckDiscretized():
         # dtype('int32') according to the rule 'safe'.
         # To fix this, change the dtype of rvs to int32 so that it
         # can bepassed to np.bincount
-        if PYTHON_IMPL_WASM:
+        if PYTHON_IMPL_WASM or sys.maxsize<2**33:
+            assert (rvs == rvs.astype(np.int32)).all()
             rvs = rvs.astype(np.int32)
         freq = np.bincount(rvs)
         p = mod.predict(res.params, which="probs", k_max=nobs_rvs)