[SciPy-User] KDTree count_neighbors

elmar elmar at net4werling.de
Fri Jul 2 15:18:11 EDT 2010


hi all,

just trying to wright a small scipts to get the distribution pattern of 
points in xy space using count_neighbors from scipy.spatial.

Here is a shortend version of the skipt:

from numpy import array
from numpy.random import uniform
from scipy.spatial import KDTree

# just to get a pattern
x = uniform(-2.0, 2.0, 200)
y = uniform(-2.0, 2.0, 200)
pattern = zip(x.ravel(), y.ravel())

tree = KDTree(pattern)

point = array([1, 0]) # just a point
r = 0.1               # and just a distance
num = tree.count_neighbors(point, r)



And here is the error messages:
num = tree.count_neighbors(point, r)
File "C:\Python26\lib\site-packages\scipy\spatial\kdtree.py", line 566, 
in count_neighbors
     R2 = Rectangle(other.maxes, other.mins)
AttributeError: 'numpy.ndarray' object has no attribute 'maxes'



Can anyone give me some support ? Any help is wellcome !

elmar




More information about the SciPy-User mailing list