File: numpy_1.11.0.patch

package info (click to toggle)
python-multipletau 0.1.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 400 kB
  • ctags: 147
  • sloc: python: 1,368; makefile: 14
file content (142 lines) | stat: -rw-r--r-- 5,546 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Description: fixes #813983, starting from Numpy 1.11.0 
 "Indexing with floats raises IndexError, e.g., a[0, 0.0]."
Author: upstream
--- python-multipletau.orig/multipletau/_multipletau.py
+++ python-multipletau/multipletau/_multipletau.py
@@ -136,11 +136,11 @@
     # Check parameters
     if np.around(m / 2) != m / 2:
         mold = 1 * m
-        m = int((np.around(m / 2) + 1) * 2)
+        m = np.int((np.around(m / 2) + 1) * 2)
         warnings.warn("Invalid value of m={}. Using m={} instead"
                       .format(mold, m))
     else:
-        m = int(m)
+        m = np.int(m)
 
     N = N0 = len(trace)
 
@@ -148,12 +148,12 @@
     # The integer k defines how many times we can average over
     # two neighboring array elements in order to obtain an array of
     # length just larger than m.
-    k = int(np.floor(np.log2(N / m)))
+    k = np.int(np.floor(np.log2(N / m)))
 
     # In the base2 multiple-tau scheme, the length of the correlation
     # array is (only taking into account values that are computed from
     # traces that are just larger than m):
-    lenG = np.int(np.floor(m + k * m / 2))
+    lenG = np.int(np.floor(m + k * m // 2))
 
     G = np.zeros((lenG, 2), dtype=dtype)
 
@@ -182,12 +182,13 @@
     # Add up every second element
     trace = (trace[:N:2] + trace[1:N + 1:2]) / 2
     N /= 2
+    N = np.int(N)
     # Start iteration for each m/2 values
     for step in range(1, k + 1):
         # Get the next m/2 values via correlation of the trace
-        for n in range(1, int(m / 2) + 1):
-            idx = int(m + n - 1 + (step - 1) * m / 2)
-            if len(trace[:N - (n + m / 2)]) == 0:
+        for n in range(1, np.int(m // 2) + 1):
+            idx = np.int(m + n - 1 + (step - 1) * m // 2)
+            if len(trace[:N - (n + m // 2)]) == 0:
                 # This is a shortcut that stops the iteration once the
                 # length of the trace is too small to compute a corre-
                 # lation. The actual length of the correlation function
@@ -211,11 +212,11 @@
                 # k in advance.
                 break
             else:
-                G[idx, 0] = deltat * (n + m / 2) * 2**step
+                G[idx, 0] = deltat * (n + m // 2) * 2**step
                 # This is the computationally intensive step
-                G[idx, 1] = np.sum(trace[:N - (n + m / 2)] *
-                                   trace[(n + m / 2):], dtype=dtype)
-                normstat[idx] = N - (n + m / 2)
+                G[idx, 1] = np.sum(trace[:N - (n + m // 2)] *
+                                   trace[(n + m // 2):], dtype=dtype)
+                normstat[idx] = N - (n + m // 2)
                 normnump[idx] = N
         # Check if len(trace) is even:
         if N % 2 == 1:
@@ -223,6 +224,7 @@
         # Add up every second element
         trace = (trace[:N:2] + trace[1:N + 1:2]) / 2
         N /= 2
+        N = np.int(N)
 
     if normalize:
         G[:, 1] /= traceavg**2 * normstat
@@ -334,11 +336,11 @@
     # Check parameters
     if np.around(m / 2) != m / 2:
         mold = 1 * m
-        m = int((np.around(m / 2) + 1) * 2)
+        m = np.int((np.around(m / 2) + 1) * 2)
         warnings.warn("Invalid value of m={}. Using m={} instead"
                       .format(mold, m))
     else:
-        m = int(m)
+        m = np.int(m)
 
     if len(a) != len(v):
         raise ValueError("Input arrays must be of equal length.")
@@ -348,12 +350,12 @@
     # The integer k defines how many times we can average over
     # two neighboring array elements in order to obtain an array of
     # length just larger than m.
-    k = int(np.floor(np.log2(N / m)))
+    k = np.int(np.floor(np.log2(N / m)))
 
     # In the base2 multiple-tau scheme, the length of the correlation
     # array is (only taking into account values that are computed from
     # traces that are just larger than m):
-    lenG = np.int(np.floor(m + k * m / 2))
+    lenG = np.int(np.floor(m + k * m // 2))
 
     G = np.zeros((lenG, 2), dtype=dtype)
     normstat = np.zeros(lenG, dtype=dtype)
@@ -379,22 +381,23 @@
     trace1 = (trace1[:N:2] + trace1[1:N + 1:2]) / 2
     trace2 = (trace2[:N:2] + trace2[1:N + 1:2]) / 2
     N /= 2
+    N = np.int(N)
 
     for step in range(1, k + 1):
         # Get the next m/2 values of the trace
-        for n in range(1, int(m / 2) + 1):
-            idx = int(m + n - 1 + (step - 1) * m / 2)
-            if len(trace1[:N - (n + m / 2)]) == 0:
+        for n in range(1, np.int(m // 2) + 1):
+            idx = np.int(m + n - 1 + (step - 1) * m // 2)
+            if len(trace1[:N - (n + m // 2)]) == 0:
                 # Abort
                 G = G[:idx - 1]
                 normstat = normstat[:idx - 1]
                 normnump = normnump[:idx - 1]
                 break
             else:
-                G[idx, 0] = deltat * (n + m / 2) * 2**step
+                G[idx, 0] = deltat * (n + m // 2) * 2**step
                 G[idx, 1] = np.sum(
-                    trace1[:N - (n + m / 2)] * trace2[(n + m / 2):])
-                normstat[idx] = N - (n + m / 2)
+                    trace1[:N - (n + m // 2)] * trace2[(n + m // 2):])
+                normstat[idx] = N - (n + m // 2)
                 normnump[idx] = N
 
         # Check if len(trace) is even:
@@ -404,6 +407,7 @@
         trace1 = (trace1[:N:2] + trace1[1:N + 1:2]) / 2
         trace2 = (trace2[:N:2] + trace2[1:N + 1:2]) / 2
         N /= 2
+        N = np.int(N)
 
     if normalize:
         G[:, 1] /= traceavg1 * traceavg2 * normstat