Python scipy.ndimage.measurements.label中可能存在的错误?

Python scipy.ndimage.measurements.label中可能存在的错误?,python,scipy,Python,Scipy,我试图用python编写一个渗流程序,我看到了一个推荐的scipy.ndimage.measurements.label来识别集群。问题是我声明要注意函数中的一些奇怪行为。应属于同一集群的某些元素正在接收不同的标签。下面是重现我的问题的代码片段 import numpy as np import scipy from scipy.ndimage import measurements grid = np.array([[0, 1, 1, 0, 1, 1, 0, 1, 0, 1],

我试图用python编写一个渗流程序,我看到了一个推荐的scipy.ndimage.measurements.label来识别集群。问题是我声明要注意函数中的一些奇怪行为。应属于同一集群的某些元素正在接收不同的标签。下面是重现我的问题的代码片段

import numpy as np
import scipy
from scipy.ndimage import measurements

grid = np.array([[0, 1, 1, 0, 1, 1, 0, 1, 0, 1],
                 [0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
                 [1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
                 [1, 0, 1, 0, 1, 1, 0, 1, 1, 1],
                 [0, 0, 1, 0, 1, 0, 0, 0, 0, 1],
                 [0, 1, 1, 1, 0, 0, 0, 0, 0, 1],
                 [0, 1, 0, 1, 1, 1, 0, 0, 1, 1],  #<- notice the last two elements
                 [1, 1, 0, 1, 1, 1, 1, 1, 1, 0],
                 [1, 0, 0, 0, 1, 1, 1, 1, 0, 1],
                 [1, 1, 1, 0, 0, 0, 1, 1, 0, 0]])

labels, nlabels = measurements.label(grid)

print "Scipy Version: ", scipy.__version__
print
print labels
将numpy导入为np
进口西皮
从scipy.ndimage导入度量
grid=np.array([[0,1,1,0,1,1,0,1,0,1],
[0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
[1, 0, 1, 0, 1, 1, 0, 1, 1, 1],
[0, 0, 1, 0, 1, 0, 0, 0, 0, 1],
[0, 1, 1, 1, 0, 0, 0, 0, 0, 1],

[0, 1, 0, 1, 1, 1, 0, 0, 1, 1],#我在0.14.0.dev-432f16b中得到了看起来正确的答案。这可能是,这似乎已被修复。如果该库用于聚集与位置相关的2d阵列,那么是的,它一定是一个错误。谢谢各位,这似乎是一个实际的错误。我暂时使用mahotas,正如@DSM posted.Upgr链接中建议的那样ade到Scipy 0.13.3是的,更新也起了作用。这很好,因为Scipy的例行程序是mahotas的两倍。
Scipy Version:  0.13.0

[[0 1 1 0 2 2 0 3 0 4]
 [0 1 0 0 0 0 0 0 5 0]
 [1 1 1 1 1 1 0 5 5 5]
 [1 0 1 0 1 1 0 5 5 5]
 [0 0 1 0 1 0 0 0 0 5]
 [0 1 1 1 0 0 0 0 0 5]
 [0 1 0 1 1 1 0 0 1 5]  #<- The last two elements
 [1 1 0 1 1 1 1 1 1 0]  #   are set with different labels
 [1 0 0 0 1 1 1 1 0 6]
 [1 1 1 0 0 0 1 1 0 0]]