Skip to content
Browse files

MAINT: Fix deprecated non-integer index to numpy arrays

  • Loading branch information...
1 parent 89c7f42 commit 62b792633f6b8e0ef9288457bc2f70420f98e625 @jseabold committed Dec 20, 2012
Showing with 10 additions and 9 deletions.
  1. +2 −2 scipy/cluster/hierarchy.py
  2. +4 −4 scipy/cluster/tests/test_hierarchy.py
  3. +1 −0 scipy/stats/mstats_extras.py
  4. +3 −3 scipy/stats/stats.py
View
4 scipy/cluster/hierarchy.py
@@ -2313,8 +2313,8 @@ def _dendrogram_calculate_info(Z, p, truncate_mode, \
# !!! Otherwise, we don't have a leaf node, so work on plotting a
# non-leaf node.
# Actual indices of a and b
- aa = Z[i - n, 0]
- ab = Z[i - n, 1]
+ aa = int(Z[i - n, 0])
+ ab = int(Z[i - n, 1])
if aa > n:
# The number of singletons below cluster a
na = Z[aa - n, 3]
View
8 scipy/cluster/tests/test_hierarchy.py
@@ -1373,9 +1373,9 @@ def calculate_maximum_distances(Z):
left = Z[i, 0]
right = Z[i, 1]
if left >= n:
- q[0] = B[left - n]
+ q[0] = B[int(left) - n]
if right >= n:
- q[1] = B[right - n]
+ q[1] = B[int(right) - n]
q[2] = Z[i, 2]
B[i] = q.max()
return B
@@ -1391,9 +1391,9 @@ def calculate_maximum_inconsistencies(Z, R, k=3):
left = Z[i, 0]
right = Z[i, 1]
if left >= n:
- q[0] = B[left - n]
+ q[0] = B[int(left) - n]
if right >= n:
- q[1] = B[right - n]
+ q[1] = B[int(right) - n]
q[2] = R[i, k]
B[i] = q.max()
return B
View
1 scipy/stats/mstats_extras.py
@@ -352,6 +352,7 @@ def _idf(data):
if n < 3:
return [np.nan,np.nan]
(j,h) = divmod(n/4. + 5/12.,1)
+ j = int(j)
qlo = (1-h)*x[j-1] + h*x[j]
k = n - j
qup = (1-h)*x[k] + h*x[k-1]
View
6 scipy/stats/stats.py
@@ -1470,15 +1470,15 @@ def scoreatpercentile(a, per, limit=(), interpolation_method='fraction'):
idx = per /100. * (values.shape[0] - 1)
if (idx % 1 == 0):
- score = values[idx]
+ score = values[int(idx)]
else:
if interpolation_method == 'fraction':
score = _interpolate(values[int(idx)], values[int(idx) + 1],
idx % 1)
elif interpolation_method == 'lower':
- score = values[np.floor(idx)]
+ score = values[int(np.floor(idx))]
elif interpolation_method == 'higher':
- score = values[np.ceil(idx)]
+ score = values[int(np.ceil(idx))]
else:
raise ValueError("interpolation_method can only be 'fraction', " \
"'lower' or 'higher'")

0 comments on commit 62b7926

Please sign in to comment.
Something went wrong with that request. Please try again.