2015-10-13 9 views
7

geçerli:VisibleDeprecationWarning: boolean dizini, boyut 1 boyunca dizinlenmiş diziyle eşleşmedi; boyut 2'dir ancak boolean boyut tekabül ben güncellenen numpy, ben uyarı alıyorum düşünüyorum, MacPorts bir güncellemeden sonra 1

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]) 

önce ileri sürülmemiş olduğunu. İlgili kodudur:

# 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]) 

self.dst tek skalerdir.

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 

Herhangi bir fikir?

cevap

12

Numune 1.10.1'e yükseldikten sonra benzer bir hata almaya başladım. Ben sadece bir numpy.where() içinde boole dizisini sarmalayarak uyarıdan kurtulabileceğinizi düşünüyorum.

inliers = n.size(pixels[n.where(distances <= self.dst)]) 

sadece boyutu alıyorsun beri orada piksel dizisini kullanmaya gerek, bu yüzden bu çalışması gerekir:

inliers = n.size(n.where(distances <= self.dst])[0])