在Macports更新后,我认为更新了numpy,我收到了警告:
VisibleDeprecationWarning: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1
inliers = n.size(pixels[distances <= self.dst])
Run Code Online (Sandbox Code Playgroud)
之前没有提过过.相关代码是:
# Compute distance of all non-zero points from the circumference
distances = guess_feature.points_distance(pixels)
# Check which points are inliers (i.e. near the circle)
inliers = n.size(pixels[distances <= self.dst])
Run Code Online (Sandbox Code Playgroud)
self.dst
是单个标量.
guess_feature.points_distance
:
def points_distance(self,points):
r'''
Compute the distance of the points from the feature
:math:`d = \left| \sqrt{(x_i - x_c)^2 + (y_i-y_c)^2} - r \right|`
Args:
points (numpy.ndarray): a (n,2) numpy array, each row is a 2D Point.
Returns:
d (numpy.ndarray): the computed distances of the points from the feature.
'''
xa = n.array([self.xc,self.yc]).reshape((1,2))
d = n.abs(dist.cdist(points,xa) - self.radius)
return d
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
I.P*_*ley 13
在进入numpy 1.10.1之后,我开始遇到类似的错误.我想你可以通过将布尔数组包装在numpy.where()中来消除警告.
inliers = n.size(pixels[n.where(distances <= self.dst)])
Run Code Online (Sandbox Code Playgroud)
由于你只是拿大小,所以不需要使用像素数组,所以这应该工作:
inliers = n.size(n.where(distances <= self.dst])[0])
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9955 次 |
最近记录: |