Unverified Commit fbe5db61 authored by Ryan Lahfa's avatar Ryan Lahfa Committed by GitHub
Browse files

Merge pull request #231662 from CedricFinance/bayespy-zhf-fix

python310Packages.bayespy: add patch to fix deprecated numpy types
parents 776fbde6 14a440a5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@ buildPythonPackage rec {
      url = "https://github.com/bayespy/bayespy/commit/9be53bada763e19c2b6086731a6aa542ad33aad0.patch";
      hash = "sha256-KYt/0GcaNWR9K9/uS2OXgK7g1Z+Bayx9+IQGU75Mpuo=";
    })

    # Fix deprecated numpy types
    # https://sources.debian.org/src/python-bayespy/0.5.22-5/debian/patches/pr127-Fix-deprecated-numpy-types.patch/
    ./pr127-Fix-deprecated-numpy-types.patch
  ];

  nativeCheckInputs = [ pytestCheckHook nose glibcLocales ];
+129 −0
Original line number Diff line number Diff line
Description: Fix deprecated numpy types
From: Antti Mäkinen <antti.makinen@danfoss.com>
Bug: https://github.com/bayespy/bayespy/pull/127
Bug-Debian: https://bugs.debian.org/1027220

--- a/bayespy/inference/vmp/nodes/categorical_markov_chain.py
+++ b/bayespy/inference/vmp/nodes/categorical_markov_chain.py
@@ -171,7 +171,7 @@ class CategoricalMarkovChainDistribution
         # Explicit broadcasting
         P = P * np.ones(plates)[...,None,None,None]
         # Allocate memory
-        Z = np.zeros(plates + (self.N,), dtype=np.int)
+        Z = np.zeros(plates + (self.N,), dtype=np.int64)
         # Draw initial state
         Z[...,0] = random.categorical(p0, size=plates)
         # Create [0,1,2,...,len(plate_axis)] indices for each plate axis and
--- a/bayespy/inference/vmp/nodes/concatenate.py
+++ b/bayespy/inference/vmp/nodes/concatenate.py
@@ -70,7 +70,7 @@ class Concatenate(Deterministic):
         )
 
         # Compute start indices for each parent on the concatenated plate axis
-        self._indices = np.zeros(len(nodes)+1, dtype=np.int)
+        self._indices = np.zeros(len(nodes)+1, dtype=np.int64)
         self._indices[1:] = np.cumsum([int(parent.plates[axis])
                                        for parent in self.parents])
         self._lengths = [parent.plates[axis] for parent in self.parents]
--- a/bayespy/inference/vmp/nodes/tests/test_binomial.py
+++ b/bayespy/inference/vmp/nodes/tests/test_binomial.py
@@ -43,7 +43,7 @@ class TestBinomial(TestCase):
         X = Binomial(10, 0.7*np.ones((4,3)))
         self.assertEqual(X.plates,
                          (4,3))
-        n = np.ones((4,3), dtype=np.int)
+        n = np.ones((4,3), dtype=np.int64)
         X = Binomial(n, 0.7)
         self.assertEqual(X.plates,
                          (4,3))
--- a/bayespy/inference/vmp/nodes/tests/test_multinomial.py
+++ b/bayespy/inference/vmp/nodes/tests/test_multinomial.py
@@ -43,7 +43,7 @@ class TestMultinomial(TestCase):
         X = Multinomial(10, 0.25*np.ones((2,3,4)))
         self.assertEqual(X.plates,
                          (2,3))
-        n = 10 * np.ones((3,4), dtype=np.int)
+        n = 10 * np.ones((3,4), dtype=np.int64)
         X = Multinomial(n, [0.1, 0.3, 0.6])
         self.assertEqual(X.plates,
                          (3,4))
--- a/bayespy/inference/vmp/nodes/tests/test_take.py
+++ b/bayespy/inference/vmp/nodes/tests/test_take.py
@@ -89,7 +89,7 @@ class TestTake(TestCase):
 
         # Test matrix indices, no shape
         X = GaussianARD(1, 1, plates=(3,), shape=(2,))
-        Y = Take(X, np.ones((4, 5), dtype=np.int))
+        Y = Take(X, np.ones((4, 5), dtype=np.int64))
         self.assertEqual(
             Y.plates,
             (4, 5),
@@ -113,7 +113,7 @@ class TestTake(TestCase):
 
         # Test vector indices with more plate axes
         X = GaussianARD(1, 1, plates=(4, 2), shape=())
-        Y = Take(X, np.ones(3, dtype=np.int))
+        Y = Take(X, np.ones(3, dtype=np.int64))
         self.assertEqual(
             Y.plates,
             (4, 3),
@@ -125,7 +125,7 @@ class TestTake(TestCase):
 
         # Test take on other plate axis
         X = GaussianARD(1, 1, plates=(4, 2), shape=())
-        Y = Take(X, np.ones(3, dtype=np.int), plate_axis=-2)
+        Y = Take(X, np.ones(3, dtype=np.int64), plate_axis=-2)
         self.assertEqual(
             Y.plates,
             (3, 2),
@@ -141,7 +141,7 @@ class TestTake(TestCase):
             ValueError,
             Take,
             X,
-            np.ones(3, dtype=np.int),
+            np.ones(3, dtype=np.int64),
             plate_axis=0,
         )
 
--- a/bayespy/utils/tests/test_linalg.py
+++ b/bayespy/utils/tests/test_linalg.py
@@ -126,7 +126,7 @@ class TestBandedSolve(misc.TestCase):
         # Random sizes of the blocks
         #D = np.random.randint(5, 10, size=N)
         # Fixed sizes of the blocks
-        D = 5*np.ones(N, dtype=np.int)
+        D = 5*np.ones(N, dtype=np.int64)
 
         # Some helpful variables to create the covariances
         W = [np.random.randn(D[i], 2*D[i])
--- a/bayespy/utils/misc.py
+++ b/bayespy/utils/misc.py
@@ -355,7 +355,7 @@ class TestCase(unittest.TestCase):
                     ]
                 )
             ]
-        ).astype(np.int)
+        ).astype(int)
 
         def pack(x):
             return [
--- a/bayespy/utils/random.py
+++ b/bayespy/utils/random.py
@@ -284,7 +284,7 @@ def categorical(p, size=None):
         for ind in inds:
             z[ind] = np.searchsorted(P[ind], x[ind])
 
-    return z.astype(np.int)
+    return z.astype(int)
 
 
 def multinomial(n, p, size=None):
@@ -313,7 +313,7 @@ def multinomial(n, p, size=None):
     for i in misc.nested_iterator(size):
         x[i] = np.random.multinomial(n[i], p[i])
 
-    return x.astype(np.int)
+    return x.astype(int)
 
 
 def gamma(a, b, size=None):